@doist/comms-sdk 0.1.0-alpha.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/clients/add-comment-helper.js +17 -0
  3. package/dist/cjs/clients/base-client.js +3 -5
  4. package/dist/cjs/clients/channels-client.js +123 -6
  5. package/dist/cjs/clients/comments-client.js +75 -9
  6. package/dist/cjs/clients/conversation-messages-client.js +76 -5
  7. package/dist/cjs/clients/conversations-client.js +143 -3
  8. package/dist/cjs/clients/groups-client.js +98 -5
  9. package/dist/cjs/clients/inbox-client.js +87 -14
  10. package/dist/cjs/clients/reactions-client.js +40 -2
  11. package/dist/cjs/clients/search-client.js +50 -0
  12. package/dist/cjs/clients/threads-client.js +211 -16
  13. package/dist/cjs/clients/users-client.js +138 -11
  14. package/dist/cjs/clients/workspace-users-client.js +110 -10
  15. package/dist/cjs/clients/workspaces-client.js +80 -7
  16. package/dist/cjs/comms-api.js +1 -0
  17. package/dist/cjs/consts/endpoints.js +8 -3
  18. package/dist/cjs/testUtils/test-defaults.js +3 -1
  19. package/dist/cjs/types/api-version.js +8 -0
  20. package/dist/cjs/types/index.js +1 -0
  21. package/dist/cjs/types/requests.js +0 -1
  22. package/dist/esm/clients/add-comment-helper.js +17 -0
  23. package/dist/esm/clients/base-client.js +3 -5
  24. package/dist/esm/clients/channels-client.js +123 -6
  25. package/dist/esm/clients/comments-client.js +75 -9
  26. package/dist/esm/clients/conversation-messages-client.js +76 -5
  27. package/dist/esm/clients/conversations-client.js +143 -3
  28. package/dist/esm/clients/groups-client.js +98 -5
  29. package/dist/esm/clients/inbox-client.js +87 -14
  30. package/dist/esm/clients/reactions-client.js +40 -2
  31. package/dist/esm/clients/search-client.js +50 -0
  32. package/dist/esm/clients/threads-client.js +211 -16
  33. package/dist/esm/clients/users-client.js +138 -11
  34. package/dist/esm/clients/workspace-users-client.js +110 -10
  35. package/dist/esm/clients/workspaces-client.js +80 -7
  36. package/dist/esm/comms-api.js +1 -0
  37. package/dist/esm/consts/endpoints.js +8 -3
  38. package/dist/esm/testUtils/test-defaults.js +2 -0
  39. package/dist/esm/types/api-version.js +5 -0
  40. package/dist/esm/types/index.js +1 -0
  41. package/dist/esm/types/requests.js +0 -1
  42. package/dist/types/clients/add-comment-helper.d.ts +17 -0
  43. package/dist/types/clients/base-client.d.ts +4 -0
  44. package/dist/types/clients/channels-client.d.ts +123 -6
  45. package/dist/types/clients/comments-client.d.ts +73 -6
  46. package/dist/types/clients/conversation-messages-client.d.ts +76 -5
  47. package/dist/types/clients/conversations-client.d.ts +143 -3
  48. package/dist/types/clients/groups-client.d.ts +98 -5
  49. package/dist/types/clients/inbox-client.d.ts +81 -5
  50. package/dist/types/clients/reactions-client.d.ts +40 -2
  51. package/dist/types/clients/search-client.d.ts +50 -0
  52. package/dist/types/clients/threads-client.d.ts +200 -8
  53. package/dist/types/clients/users-client.d.ts +138 -11
  54. package/dist/types/clients/workspace-users-client.d.ts +110 -10
  55. package/dist/types/clients/workspaces-client.d.ts +80 -7
  56. package/dist/types/comms-api.d.ts +3 -0
  57. package/dist/types/consts/endpoints.d.ts +6 -1
  58. package/dist/types/testUtils/test-defaults.d.ts +1 -0
  59. package/dist/types/types/api-version.d.ts +6 -0
  60. package/dist/types/types/index.d.ts +1 -0
  61. package/dist/types/types/requests.d.ts +2 -21
  62. package/package.json +1 -1
@@ -5,16 +5,92 @@ import { BaseClient } from './base-client.js';
5
5
  export declare class InboxClient extends BaseClient {
6
6
  /**
7
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
+ * ```
8
31
  */
9
32
  getInbox(args: GetInboxArgs): Promise<InboxThread[]>;
10
- /** Gets unread count for inbox. */
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
+ */
11
45
  getCount(workspaceId: number): Promise<number>;
12
- /** Archives a thread in the inbox. */
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
+ */
13
56
  archiveThread(id: string): Promise<void>;
14
- /** Unarchives a thread in the inbox. */
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
+ */
15
67
  unarchiveThread(id: string): Promise<void>;
16
- /** Marks all inbox items as read in a workspace. */
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
+ */
17
78
  markAllRead(workspaceId: number): Promise<void>;
18
- /** Archives all inbox items in a workspace. */
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
+ */
19
95
  archiveAll(args: ArchiveAllArgs): Promise<void>;
20
96
  }
@@ -5,15 +5,53 @@ import { BaseClient } from './base-client.js';
5
5
  * Client for interacting with Comms reaction endpoints.
6
6
  */
7
7
  export declare class ReactionsClient extends BaseClient {
8
- /** Adds an emoji reaction to a thread, comment, or conversation message. */
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
+ */
9
22
  add(args: AddReactionArgs): Promise<void>;
10
23
  /**
11
24
  * Gets reactions for a thread, comment, or conversation message.
12
25
  *
13
26
  * Returns an object with emoji reactions as keys and arrays of user IDs as
14
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
+ * ```
15
40
  */
16
41
  get(args: GetReactionsArgs): Promise<ReactionObject>;
17
- /** Removes an emoji reaction from a thread, comment, or conversation message. */
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
+ */
18
56
  remove(args: RemoveReactionArgs): Promise<void>;
19
57
  }
@@ -7,14 +7,64 @@ import { BaseClient } from './base-client.js';
7
7
  export declare class SearchClient extends BaseClient {
8
8
  /**
9
9
  * Searches across all threads and conversations in a workspace.
10
+ *
11
+ * @param args - The arguments for searching.
12
+ * @param args.query - The search query string. Optional when `mentionSelf: true` is set; required otherwise.
13
+ * @param args.workspaceId - The workspace ID to search in.
14
+ * @param args.channelIds - Optional array of channel IDs to filter by.
15
+ * @param args.authorIds - Optional array of author user IDs to filter by.
16
+ * @param args.mentionSelf - Optional flag to filter by mentions of the current user. When true, `query` may be omitted.
17
+ * @param args.dateFrom - Optional start date for filtering (YYYY-MM-DD).
18
+ * @param args.dateTo - Optional end date for filtering (YYYY-MM-DD).
19
+ * @param args.limit - Optional limit on number of results returned.
20
+ * @param args.cursor - Optional cursor for pagination.
21
+ * @returns Search results with pagination.
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * const results = await api.search.search({
26
+ * query: 'important meeting',
27
+ * workspaceId: 123,
28
+ * })
29
+ * ```
10
30
  */
11
31
  search(args: SearchArgs): Promise<SearchResponse>;
12
32
  /**
13
33
  * Searches within comments of a specific thread.
34
+ *
35
+ * @param args - The arguments for searching within a thread.
36
+ * @param args.query - The search query string.
37
+ * @param args.threadId - The thread ID to search in.
38
+ * @param args.limit - Optional limit on number of results returned.
39
+ * @param args.cursor - Optional cursor for pagination.
40
+ * @returns Comment IDs that match the search query.
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * const results = await api.search.searchThread({
45
+ * query: 'deadline',
46
+ * threadId: '7YpL3oZ4kZ9vP7Q1tR2sX3z',
47
+ * })
48
+ * ```
14
49
  */
15
50
  searchThread(args: SearchThreadArgs): Promise<SearchThreadResponse>;
16
51
  /**
17
52
  * Searches within messages of a specific conversation.
53
+ *
54
+ * @param args - The arguments for searching within a conversation.
55
+ * @param args.query - The search query string.
56
+ * @param args.conversationId - The conversation ID to search in.
57
+ * @param args.limit - Optional limit on number of results returned.
58
+ * @param args.cursor - Optional cursor for pagination.
59
+ * @returns Message IDs that match the search query.
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * const results = await api.search.searchConversation({
64
+ * query: 'budget',
65
+ * conversationId: '7YpL3oZ4kZ9vP7Q1tR2sX42',
66
+ * })
67
+ * ```
18
68
  */
19
69
  searchConversation(args: SearchConversationArgs): Promise<SearchConversationResponse>;
20
70
  }
@@ -293,51 +293,243 @@ export declare const ThreadListSchema: z.ZodArray<z.ZodPipe<z.ZodObject<{
293
293
  */
294
294
  export declare class ThreadsClient extends BaseClient {
295
295
  /**
296
- * Lists threads. At least one of `channelId` / `workspaceId` is required.
296
+ * Gets threads. At least one of `channelId` / `workspaceId` is required.
297
297
  * `newerThan` / `olderThan` (`Date`) are converted to the
298
298
  * `newer_than_ts` / `older_than_ts` epoch-second params on the wire.
299
+ *
300
+ * @param args - The arguments for getting threads.
301
+ * @param args.workspaceId - The workspace ID.
302
+ * @param args.channelId - Optional channel ID to narrow to a single channel.
303
+ * @param args.archived - Optional flag to include archived threads.
304
+ * @param args.newerThan - Optional date to get threads newer than.
305
+ * @param args.olderThan - Optional date to get threads older than.
306
+ * @param args.limit - Optional limit on number of threads returned.
307
+ * @returns An array of thread objects.
308
+ *
309
+ * @example
310
+ * ```typescript
311
+ * const threads = await api.threads.getThreads({
312
+ * workspaceId: 123,
313
+ * channelId: '7YpL3oZ4kZ9vP7Q1tR2sX44',
314
+ * })
315
+ * threads.forEach(t => console.log(t.title))
316
+ * ```
299
317
  */
300
318
  getThreads(args: GetThreadsArgs): Promise<Thread[]>;
301
- /** Fetches a single thread by ID. */
319
+ /**
320
+ * Gets a single thread object by id.
321
+ *
322
+ * @param id - The thread ID.
323
+ * @returns The thread object.
324
+ */
302
325
  getThread(id: string): Promise<Thread>;
303
- /** Creates a new thread. `id` is auto-generated if not supplied. */
326
+ /**
327
+ * Creates a new thread in a channel. `id` is auto-generated if not supplied.
328
+ *
329
+ * @param args - The arguments for creating a thread.
330
+ * @param args.channelId - The channel ID.
331
+ * @param args.title - Optional thread title.
332
+ * @param args.content - The thread content.
333
+ * @param args.recipients - Optional array of user IDs to notify.
334
+ * @param args.groups - Optional array of custom group IDs to notify.
335
+ * @returns The created thread object.
336
+ *
337
+ * @example
338
+ * ```typescript
339
+ * const thread = await api.threads.createThread({
340
+ * channelId: '7YpL3oZ4kZ9vP7Q1tR2sX44',
341
+ * title: 'New Feature Discussion',
342
+ * content: 'Let\'s discuss the new feature...',
343
+ * })
344
+ * ```
345
+ */
304
346
  createThread(args: CreateThreadArgs): Promise<Thread>;
305
- /** Partial update of an existing thread. */
347
+ /**
348
+ * Partial update of an existing thread.
349
+ *
350
+ * @param args - The arguments for updating a thread.
351
+ * @param args.id - The thread ID.
352
+ * @param args.title - Optional new thread title.
353
+ * @param args.content - Optional new thread content.
354
+ * @returns The updated thread object.
355
+ */
306
356
  updateThread(args: UpdateThreadArgs): Promise<Thread>;
307
- /** Permanently deletes a thread. */
357
+ /**
358
+ * Permanently deletes a thread.
359
+ *
360
+ * @param id - The thread ID.
361
+ */
308
362
  deleteThread(id: string): Promise<StatusOk>;
309
- /** Saves a thread (formerly "star"). */
363
+ /**
364
+ * Saves a thread (formerly "star").
365
+ *
366
+ * @param id - The thread ID.
367
+ */
310
368
  saveThread(id: string): Promise<StatusOk>;
311
- /** Unsaves a thread (formerly "unstar"). */
369
+ /**
370
+ * Unsaves a thread (formerly "unstar").
371
+ *
372
+ * @param id - The thread ID.
373
+ */
312
374
  unsaveThread(id: string): Promise<StatusOk>;
375
+ /**
376
+ * Pins a thread.
377
+ *
378
+ * @param id - The thread ID.
379
+ */
313
380
  pinThread(id: string): Promise<StatusOk>;
381
+ /**
382
+ * Unpins a thread.
383
+ *
384
+ * @param id - The thread ID.
385
+ */
314
386
  unpinThread(id: string): Promise<StatusOk>;
315
- /** Moves a thread to another channel. */
387
+ /**
388
+ * Moves a thread to another channel.
389
+ *
390
+ * @param args - The arguments for moving a thread.
391
+ * @param args.id - The thread ID.
392
+ * @param args.toChannel - The target channel ID.
393
+ * @returns The updated thread object.
394
+ */
316
395
  moveToChannel(args: MoveThreadToChannelArgs): Promise<Thread>;
396
+ /**
397
+ * Marks a thread as read.
398
+ *
399
+ * @param args - The arguments for marking a thread as read.
400
+ * @param args.id - The thread ID.
401
+ * @param args.objIndex - The index of the last known read message.
402
+ */
317
403
  markRead(args: MarkThreadReadArgs): Promise<StatusOk>;
404
+ /**
405
+ * Marks a thread as unread.
406
+ *
407
+ * @param args - The arguments for marking a thread as unread.
408
+ * @param args.id - The thread ID.
409
+ * @param args.objIndex - The index of the last unread message. Use -1 to mark the whole thread as unread.
410
+ */
318
411
  markUnread(args: MarkThreadUnreadArgs): Promise<StatusOk>;
412
+ /**
413
+ * Marks a thread as unread for others. Useful to notify others about thread changes.
414
+ *
415
+ * @param args - The arguments for marking a thread as unread for others.
416
+ * @param args.id - The thread ID.
417
+ * @param args.objIndex - The index of the last unread message. Use -1 to mark the whole thread as unread.
418
+ */
319
419
  markUnreadForOthers(args: MarkThreadUnreadForOthersArgs): Promise<StatusOk>;
320
420
  /**
321
421
  * Marks every thread in a workspace or channel as read. Exactly one of
322
422
  * `workspaceId` / `channelId` should be set.
423
+ *
424
+ * @param args - Either workspaceId or channelId (one is required).
425
+ * @param args.workspaceId - The workspace ID.
426
+ * @param args.channelId - The channel ID.
427
+ *
428
+ * @example
429
+ * ```typescript
430
+ * // Mark all in workspace
431
+ * await api.threads.markAllRead({ workspaceId: 123 })
432
+ *
433
+ * // Mark all in channel
434
+ * await api.threads.markAllRead({ channelId: '7YpL3oZ4kZ9vP7Q1tR2sX44' })
435
+ * ```
323
436
  */
324
437
  markAllRead(args: {
325
438
  workspaceId?: number;
326
439
  channelId?: string;
327
440
  }): Promise<StatusOk>;
441
+ /**
442
+ * Clears unread threads in a workspace.
443
+ *
444
+ * @param workspaceId - The workspace ID.
445
+ */
328
446
  clearUnread(workspaceId: number): Promise<StatusOk>;
329
447
  /**
330
448
  * Returns unread threads for a workspace, paired with the unread version
331
449
  * counter and (optionally) the inbox unread count.
450
+ *
451
+ * @param workspaceId - The workspace ID.
452
+ * @returns Object containing the array of unread thread references, a version counter, and optionally the inbox unread count.
332
453
  */
333
454
  getUnread(workspaceId: number): Promise<{
334
455
  data: UnreadThread[];
335
456
  version: number;
336
457
  inboxUnread?: number | null;
337
458
  }>;
459
+ /**
460
+ * Mutes a thread for a specified number of minutes.
461
+ * When muted, you will not get notified in your inbox about new comments.
462
+ *
463
+ * @param args - The arguments for muting a thread.
464
+ * @param args.id - The thread ID.
465
+ * @param args.minutes - Number of minutes to mute the thread.
466
+ * @returns The updated thread object.
467
+ *
468
+ * @example
469
+ * ```typescript
470
+ * const thread = await api.threads.muteThread({ id: '7YpL3oZ4kZ9vP7Q1tR2sX3z', minutes: 30 })
471
+ * ```
472
+ */
338
473
  muteThread(args: MuteThreadArgs): Promise<Thread>;
474
+ /**
475
+ * Unmutes a thread.
476
+ * You will start to see notifications in your inbox again when new comments are added.
477
+ *
478
+ * @param id - The thread ID.
479
+ * @returns The updated thread object.
480
+ */
339
481
  unmuteThread(id: string): Promise<Thread>;
482
+ /**
483
+ * Closes a thread by adding a comment with a close action.
484
+ *
485
+ * @param args - The arguments for closing a thread.
486
+ * @param args.id - The thread ID.
487
+ * @param args.content - The comment content.
488
+ * @param args.attachments - Optional array of {@link Attachment} objects.
489
+ * @param args.actions - Optional array of action objects.
490
+ * @param args.recipients - Optional array of user IDs to notify directly.
491
+ * @param args.groups - Optional array of custom group IDs to notify.
492
+ * @param args.directMentions - Optional array of user IDs that were @-mentioned in
493
+ * `content`.
494
+ * @param args.notifyAudience - Optional broader audience to notify in addition to
495
+ * `recipients` and `groups`. `'channel'` notifies everyone in the channel;
496
+ * `'thread'` notifies everyone who has interacted with the thread.
497
+ * @returns The created comment object.
498
+ *
499
+ * @example
500
+ * ```typescript
501
+ * const comment = await api.threads.closeThread({
502
+ * id: '7YpL3oZ4kZ9vP7Q1tR2sX3z',
503
+ * content: 'Closing this thread — resolved.',
504
+ * })
505
+ * ```
506
+ */
340
507
  closeThread(args: CloseThreadArgs): Promise<Comment>;
508
+ /**
509
+ * Reopens a thread by adding a comment with a reopen action.
510
+ *
511
+ * @param args - The arguments for reopening a thread.
512
+ * @param args.id - The thread ID.
513
+ * @param args.content - The comment content.
514
+ * @param args.attachments - Optional array of {@link Attachment} objects.
515
+ * @param args.actions - Optional array of action objects.
516
+ * @param args.recipients - Optional array of user IDs to notify directly.
517
+ * @param args.groups - Optional array of custom group IDs to notify.
518
+ * @param args.directMentions - Optional array of user IDs that were @-mentioned in
519
+ * `content`.
520
+ * @param args.notifyAudience - Optional broader audience to notify in addition to
521
+ * `recipients` and `groups`. `'channel'` notifies everyone in the channel;
522
+ * `'thread'` notifies everyone who has interacted with the thread.
523
+ * @returns The created comment object.
524
+ *
525
+ * @example
526
+ * ```typescript
527
+ * const comment = await api.threads.reopenThread({
528
+ * id: '7YpL3oZ4kZ9vP7Q1tR2sX3z',
529
+ * content: 'Reopening — need further discussion.',
530
+ * })
531
+ * ```
532
+ */
341
533
  reopenThread(args: ReopenThreadArgs): Promise<Comment>;
342
534
  private addCommentWithAction;
343
535
  private simple;
@@ -38,82 +38,209 @@ type MfaChallengeArgs = {
38
38
  * `loginWithTodoist` are the available entry points.
39
39
  */
40
40
  export declare class UsersClient extends BaseClient {
41
- /** Registers a new user via the Todoist-ID bridge. */
41
+ /**
42
+ * Registers a new user via the Todoist-ID bridge.
43
+ *
44
+ * @param args - Registration arguments.
45
+ * @param args.name - The new user's full name.
46
+ * @param args.email - The new user's email.
47
+ * @param args.password - The new user's password.
48
+ * @param args.lang - Optional preferred language.
49
+ * @param args.acceptTerms - Optional flag confirming the user accepts the terms of service.
50
+ * @returns The newly registered user object.
51
+ */
42
52
  register(args: RegisterArgs): Promise<User>;
43
- /** Logs in an existing user. */
53
+ /**
54
+ * Logs in an existing user.
55
+ *
56
+ * @param args - Login credentials.
57
+ * @param args.email - The user's email.
58
+ * @param args.password - The user's password.
59
+ * @param args.setSessionCookie - Optional flag to set a session cookie (default: true).
60
+ * @returns The authenticated user object.
61
+ *
62
+ * @example
63
+ * ```typescript
64
+ * const user = await api.users.login({
65
+ * email: 'user@example.com',
66
+ * password: 'secret',
67
+ * })
68
+ * ```
69
+ */
44
70
  login(args: LoginArgs): Promise<User>;
45
71
  /**
46
72
  * Logs in using a valid token (sent via Authorization header). The SDK
47
73
  * client is already configured with the token, so no args are needed.
74
+ *
75
+ * @returns The authenticated user object.
48
76
  */
49
77
  loginWithToken(): Promise<User>;
50
78
  /**
51
79
  * Exchanges the browser's Todoist web-session cookie for a Comms session.
52
80
  * Only useful when running in a browser context on the shared Todoist
53
81
  * registrable domain — the cookie is sent automatically by the browser.
82
+ *
83
+ * @returns The authenticated user object.
54
84
  */
55
85
  loginWithTodoist(): Promise<User>;
56
- /** Logs in (and auto-signs-up) via a Google ID token. */
86
+ /**
87
+ * Logs in (and auto-signs-up) via a Google ID token.
88
+ *
89
+ * @param args - Google login arguments.
90
+ * @param args.idToken - The Google ID token.
91
+ * @param args.nonce - The nonce that was sent to Google.
92
+ * @param args.timezone - Optional user timezone.
93
+ * @param args.lang - Optional preferred language.
94
+ * @param args.mfaToken - Optional MFA token from a prior `mfaChallenge` response.
95
+ * @returns The authenticated user object.
96
+ */
57
97
  loginWithGoogle(args: LoginWithGoogleArgs): Promise<User>;
58
98
  /**
59
99
  * Completes an MFA challenge issued by `loginWithGoogle` (returns an MFA
60
100
  * token to pass back to `loginWithGoogle.mfaToken`).
101
+ *
102
+ * @param args - MFA challenge arguments.
103
+ * @param args.challengeId - The challenge ID from the prior login attempt.
104
+ * @param args.factor - The MFA factor identifier.
105
+ * @param args.methodType - The MFA method type.
106
+ * @returns The MFA token to forward to `loginWithGoogle`.
61
107
  */
62
108
  mfaChallenge(args: MfaChallengeArgs): Promise<MfaChallengeResponse>;
63
109
  /** Logs out the current user and clears the session cookie. */
64
110
  logout(): Promise<void>;
65
- /** Returns the user associated with the current access token. */
111
+ /**
112
+ * Gets the user associated with the current access token.
113
+ *
114
+ * @returns The authenticated user's information.
115
+ *
116
+ * @example
117
+ * ```typescript
118
+ * const user = await api.users.getSessionUser()
119
+ * console.log(user.fullName, user.email)
120
+ * ```
121
+ */
66
122
  getSessionUser(): Promise<User>;
67
123
  /**
68
124
  * Fetches a single user. Defaults to the session user when no `id` is
69
125
  * passed. Cross-workspace lookups require that the caller and the target
70
126
  * share a workspace.
127
+ *
128
+ * @param args - Optional lookup arguments.
129
+ * @param args.id - The user ID. Defaults to the session user.
130
+ * @param args.workspaceId - Optional workspace ID for cross-workspace lookups.
131
+ * @param args.asList - Optional flag controlling list-style response.
132
+ * @returns The user object.
71
133
  */
72
134
  getUser(args?: {
73
135
  id?: number;
74
136
  workspaceId?: number;
75
137
  asList?: boolean;
76
138
  }): Promise<User>;
77
- /** Looks up a user by their email address. */
139
+ /**
140
+ * Looks up a user by their email address.
141
+ *
142
+ * @param email - The email to look up.
143
+ * @returns The user object.
144
+ */
78
145
  getUserByEmail(email: string): Promise<User>;
79
146
  /**
80
147
  * Updates the logged-in user's profile. Most fields are proxied to
81
148
  * Todoist (full name, password, language, timezone, etc.).
149
+ *
150
+ * @param args - The user properties to update.
151
+ * @returns The updated user object.
152
+ *
153
+ * @example
154
+ * ```typescript
155
+ * const user = await api.users.update({
156
+ * name: 'John Doe',
157
+ * timezone: 'America/New_York',
158
+ * })
159
+ * ```
82
160
  */
83
161
  update(args: UpdateUserArgs): Promise<User>;
84
- /** Updates the user's password. Requires `currentPassword`. */
162
+ /**
163
+ * Updates the user's password.
164
+ *
165
+ * @param args - Password update arguments.
166
+ * @param args.newPassword - The new password.
167
+ * @param args.currentPassword - The user's existing password. Optional — sent for
168
+ * re-authentication when the account has a password set.
169
+ * @returns The updated user object.
170
+ */
85
171
  updatePassword(args: {
86
172
  newPassword: string;
87
173
  currentPassword?: string;
88
174
  }): Promise<User>;
89
- /** Removes the user's avatar. */
175
+ /**
176
+ * Removes the user's avatar.
177
+ *
178
+ * @returns The updated user object.
179
+ */
90
180
  removeAvatar(): Promise<User>;
91
181
  /**
92
182
  * Invalidates the current API token and returns the user with a fresh
93
183
  * token.
184
+ *
185
+ * @returns The user object with the new token.
186
+ *
187
+ * @example
188
+ * ```typescript
189
+ * const user = await api.users.invalidateToken()
190
+ * console.log('New token:', user.token)
191
+ * ```
94
192
  */
95
193
  invalidateToken(): Promise<User>;
96
194
  /**
97
195
  * Validates that an arbitrary token is still active. Note this is sent
98
196
  * as a GET — the token is read from the query string, not the
99
197
  * Authorization header.
198
+ *
199
+ * @param token - The token to validate.
100
200
  */
101
201
  validateToken(token: string): Promise<void>;
102
- /** Marks the user as active on a workspace (presence beacon). */
202
+ /**
203
+ * Marks the user as active on a workspace (presence beacon).
204
+ *
205
+ * @param args - Heartbeat arguments.
206
+ * @param args.workspaceId - The workspace ID.
207
+ * @param args.platform - The platform identifier (e.g., 'mobile', 'desktop', 'api').
208
+ *
209
+ * @example
210
+ * ```typescript
211
+ * await api.users.heartbeat({ workspaceId: 123, platform: 'api' })
212
+ * ```
213
+ */
103
214
  heartbeat(args: {
104
215
  workspaceId: number;
105
216
  platform: string;
106
217
  }): Promise<void>;
107
- /** Resets the user's presence for a workspace. */
218
+ /**
219
+ * Resets the user's presence for a workspace (marks the user as inactive).
220
+ *
221
+ * @param workspaceId - The workspace ID.
222
+ */
108
223
  resetPresence(workspaceId: number): Promise<void>;
109
- /** Checks whether an email address is registered (and verified). */
224
+ /**
225
+ * Checks whether an email address is registered (and verified).
226
+ *
227
+ * @param email - The email to check.
228
+ * @returns Object indicating whether the email exists and is verified.
229
+ */
110
230
  checkEmail(email: string): Promise<EmailExistsResponse>;
111
231
  /**
112
232
  * Returns the current per-channel mail unsubscribe settings for the
113
233
  * caller's primary email.
234
+ *
235
+ * @returns Object mapping email-type keys to their opt-out flag.
114
236
  */
115
237
  getUnsubscribeSettings(): Promise<Record<string, boolean>>;
116
- /** Toggles per-email-type opt-out settings. */
238
+ /**
239
+ * Toggles per-email-type opt-out settings.
240
+ *
241
+ * @param settings - Object mapping email-type keys to their opt-out flag.
242
+ * @returns Status object with `"ok"` status.
243
+ */
117
244
  updateUnsubscribeSettings(settings: Record<string, boolean>): Promise<{
118
245
  status: string;
119
246
  }>;