@doist/comms-sdk 0.1.0-alpha.1 → 0.2.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.
- package/README.md +1 -1
- package/dist/cjs/clients/add-comment-helper.js +18 -2
- package/dist/cjs/clients/base-client.js +11 -5
- package/dist/cjs/clients/channels-client.js +142 -14
- package/dist/cjs/clients/comments-client.js +99 -14
- package/dist/cjs/clients/conversation-messages-client.js +91 -9
- package/dist/cjs/clients/conversations-client.js +166 -15
- package/dist/cjs/clients/groups-client.js +98 -5
- package/dist/cjs/clients/inbox-client.js +102 -16
- package/dist/cjs/clients/reactions-client.js +40 -2
- package/dist/cjs/clients/search-client.js +50 -0
- package/dist/cjs/clients/threads-client.js +238 -24
- package/dist/cjs/clients/users-client.js +138 -11
- package/dist/cjs/clients/workspace-users-client.js +110 -10
- package/dist/cjs/clients/workspaces-client.js +89 -8
- package/dist/cjs/comms-api.js +1 -0
- package/dist/cjs/consts/endpoints.js +8 -3
- package/dist/cjs/testUtils/test-defaults.js +3 -1
- package/dist/cjs/types/api-version.js +8 -0
- package/dist/cjs/types/entities.js +119 -98
- package/dist/cjs/types/index.js +1 -0
- package/dist/cjs/types/requests.js +0 -1
- package/dist/cjs/utils/url-helpers.js +3 -1
- package/dist/esm/clients/add-comment-helper.js +18 -2
- package/dist/esm/clients/base-client.js +11 -5
- package/dist/esm/clients/channels-client.js +143 -15
- package/dist/esm/clients/comments-client.js +100 -15
- package/dist/esm/clients/conversation-messages-client.js +92 -10
- package/dist/esm/clients/conversations-client.js +167 -16
- package/dist/esm/clients/groups-client.js +98 -5
- package/dist/esm/clients/inbox-client.js +102 -16
- package/dist/esm/clients/reactions-client.js +40 -2
- package/dist/esm/clients/search-client.js +50 -0
- package/dist/esm/clients/threads-client.js +239 -25
- package/dist/esm/clients/users-client.js +138 -11
- package/dist/esm/clients/workspace-users-client.js +110 -10
- package/dist/esm/clients/workspaces-client.js +90 -9
- package/dist/esm/comms-api.js +1 -0
- package/dist/esm/consts/endpoints.js +8 -3
- package/dist/esm/testUtils/test-defaults.js +2 -0
- package/dist/esm/types/api-version.js +5 -0
- package/dist/esm/types/entities.js +111 -97
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/types/requests.js +0 -1
- package/dist/esm/utils/url-helpers.js +3 -1
- package/dist/types/clients/add-comment-helper.d.ts +20 -1
- package/dist/types/clients/base-client.d.ts +10 -0
- package/dist/types/clients/channels-client.d.ts +126 -6
- package/dist/types/clients/comments-client.d.ts +77 -6
- package/dist/types/clients/conversation-messages-client.d.ts +79 -5
- package/dist/types/clients/conversations-client.d.ts +146 -3
- package/dist/types/clients/groups-client.d.ts +98 -5
- package/dist/types/clients/inbox-client.d.ts +463 -5
- package/dist/types/clients/reactions-client.d.ts +40 -2
- package/dist/types/clients/search-client.d.ts +50 -0
- package/dist/types/clients/threads-client.d.ts +204 -8
- package/dist/types/clients/users-client.d.ts +138 -11
- package/dist/types/clients/workspace-users-client.d.ts +110 -10
- package/dist/types/clients/workspaces-client.d.ts +82 -7
- package/dist/types/comms-api.d.ts +3 -0
- package/dist/types/consts/endpoints.d.ts +6 -1
- package/dist/types/testUtils/test-defaults.d.ts +1 -0
- package/dist/types/types/api-version.d.ts +6 -0
- package/dist/types/types/entities.d.ts +1654 -126
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/requests.d.ts +2 -21
- package/package.json +1 -1
|
@@ -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
|
}
|
|
@@ -292,52 +292,248 @@ export declare const ThreadListSchema: z.ZodArray<z.ZodPipe<z.ZodObject<{
|
|
|
292
292
|
* `createThread` when the caller doesn't supply one.
|
|
293
293
|
*/
|
|
294
294
|
export declare class ThreadsClient extends BaseClient {
|
|
295
|
+
private readonly linkBaseUrl;
|
|
296
|
+
private readonly threadSchema;
|
|
297
|
+
private readonly threadListSchema;
|
|
298
|
+
private readonly commentSchema;
|
|
295
299
|
/**
|
|
296
|
-
*
|
|
300
|
+
* Gets threads. At least one of `channelId` / `workspaceId` is required.
|
|
297
301
|
* `newerThan` / `olderThan` (`Date`) are converted to the
|
|
298
302
|
* `newer_than_ts` / `older_than_ts` epoch-second params on the wire.
|
|
303
|
+
*
|
|
304
|
+
* @param args - The arguments for getting threads.
|
|
305
|
+
* @param args.workspaceId - The workspace ID.
|
|
306
|
+
* @param args.channelId - Optional channel ID to narrow to a single channel.
|
|
307
|
+
* @param args.archived - Optional flag to include archived threads.
|
|
308
|
+
* @param args.newerThan - Optional date to get threads newer than.
|
|
309
|
+
* @param args.olderThan - Optional date to get threads older than.
|
|
310
|
+
* @param args.limit - Optional limit on number of threads returned.
|
|
311
|
+
* @returns An array of thread objects.
|
|
312
|
+
*
|
|
313
|
+
* @example
|
|
314
|
+
* ```typescript
|
|
315
|
+
* const threads = await api.threads.getThreads({
|
|
316
|
+
* workspaceId: 123,
|
|
317
|
+
* channelId: '7YpL3oZ4kZ9vP7Q1tR2sX44',
|
|
318
|
+
* })
|
|
319
|
+
* threads.forEach(t => console.log(t.title))
|
|
320
|
+
* ```
|
|
299
321
|
*/
|
|
300
322
|
getThreads(args: GetThreadsArgs): Promise<Thread[]>;
|
|
301
|
-
/**
|
|
323
|
+
/**
|
|
324
|
+
* Gets a single thread object by id.
|
|
325
|
+
*
|
|
326
|
+
* @param id - The thread ID.
|
|
327
|
+
* @returns The thread object.
|
|
328
|
+
*/
|
|
302
329
|
getThread(id: string): Promise<Thread>;
|
|
303
|
-
/**
|
|
330
|
+
/**
|
|
331
|
+
* Creates a new thread in a channel. `id` is auto-generated if not supplied.
|
|
332
|
+
*
|
|
333
|
+
* @param args - The arguments for creating a thread.
|
|
334
|
+
* @param args.channelId - The channel ID.
|
|
335
|
+
* @param args.title - Optional thread title.
|
|
336
|
+
* @param args.content - The thread content.
|
|
337
|
+
* @param args.recipients - Optional array of user IDs to notify.
|
|
338
|
+
* @param args.groups - Optional array of custom group IDs to notify.
|
|
339
|
+
* @returns The created thread object.
|
|
340
|
+
*
|
|
341
|
+
* @example
|
|
342
|
+
* ```typescript
|
|
343
|
+
* const thread = await api.threads.createThread({
|
|
344
|
+
* channelId: '7YpL3oZ4kZ9vP7Q1tR2sX44',
|
|
345
|
+
* title: 'New Feature Discussion',
|
|
346
|
+
* content: 'Let\'s discuss the new feature...',
|
|
347
|
+
* })
|
|
348
|
+
* ```
|
|
349
|
+
*/
|
|
304
350
|
createThread(args: CreateThreadArgs): Promise<Thread>;
|
|
305
|
-
/**
|
|
351
|
+
/**
|
|
352
|
+
* Partial update of an existing thread.
|
|
353
|
+
*
|
|
354
|
+
* @param args - The arguments for updating a thread.
|
|
355
|
+
* @param args.id - The thread ID.
|
|
356
|
+
* @param args.title - Optional new thread title.
|
|
357
|
+
* @param args.content - Optional new thread content.
|
|
358
|
+
* @returns The updated thread object.
|
|
359
|
+
*/
|
|
306
360
|
updateThread(args: UpdateThreadArgs): Promise<Thread>;
|
|
307
|
-
/**
|
|
361
|
+
/**
|
|
362
|
+
* Permanently deletes a thread.
|
|
363
|
+
*
|
|
364
|
+
* @param id - The thread ID.
|
|
365
|
+
*/
|
|
308
366
|
deleteThread(id: string): Promise<StatusOk>;
|
|
309
|
-
/**
|
|
367
|
+
/**
|
|
368
|
+
* Saves a thread (formerly "star").
|
|
369
|
+
*
|
|
370
|
+
* @param id - The thread ID.
|
|
371
|
+
*/
|
|
310
372
|
saveThread(id: string): Promise<StatusOk>;
|
|
311
|
-
/**
|
|
373
|
+
/**
|
|
374
|
+
* Unsaves a thread (formerly "unstar").
|
|
375
|
+
*
|
|
376
|
+
* @param id - The thread ID.
|
|
377
|
+
*/
|
|
312
378
|
unsaveThread(id: string): Promise<StatusOk>;
|
|
379
|
+
/**
|
|
380
|
+
* Pins a thread.
|
|
381
|
+
*
|
|
382
|
+
* @param id - The thread ID.
|
|
383
|
+
*/
|
|
313
384
|
pinThread(id: string): Promise<StatusOk>;
|
|
385
|
+
/**
|
|
386
|
+
* Unpins a thread.
|
|
387
|
+
*
|
|
388
|
+
* @param id - The thread ID.
|
|
389
|
+
*/
|
|
314
390
|
unpinThread(id: string): Promise<StatusOk>;
|
|
315
|
-
/**
|
|
391
|
+
/**
|
|
392
|
+
* Moves a thread to another channel.
|
|
393
|
+
*
|
|
394
|
+
* @param args - The arguments for moving a thread.
|
|
395
|
+
* @param args.id - The thread ID.
|
|
396
|
+
* @param args.toChannel - The target channel ID.
|
|
397
|
+
* @returns The updated thread object.
|
|
398
|
+
*/
|
|
316
399
|
moveToChannel(args: MoveThreadToChannelArgs): Promise<Thread>;
|
|
400
|
+
/**
|
|
401
|
+
* Marks a thread as read.
|
|
402
|
+
*
|
|
403
|
+
* @param args - The arguments for marking a thread as read.
|
|
404
|
+
* @param args.id - The thread ID.
|
|
405
|
+
* @param args.objIndex - The index of the last known read message.
|
|
406
|
+
*/
|
|
317
407
|
markRead(args: MarkThreadReadArgs): Promise<StatusOk>;
|
|
408
|
+
/**
|
|
409
|
+
* Marks a thread as unread.
|
|
410
|
+
*
|
|
411
|
+
* @param args - The arguments for marking a thread as unread.
|
|
412
|
+
* @param args.id - The thread ID.
|
|
413
|
+
* @param args.objIndex - The index of the last unread message. Use -1 to mark the whole thread as unread.
|
|
414
|
+
*/
|
|
318
415
|
markUnread(args: MarkThreadUnreadArgs): Promise<StatusOk>;
|
|
416
|
+
/**
|
|
417
|
+
* Marks a thread as unread for others. Useful to notify others about thread changes.
|
|
418
|
+
*
|
|
419
|
+
* @param args - The arguments for marking a thread as unread for others.
|
|
420
|
+
* @param args.id - The thread ID.
|
|
421
|
+
* @param args.objIndex - The index of the last unread message. Use -1 to mark the whole thread as unread.
|
|
422
|
+
*/
|
|
319
423
|
markUnreadForOthers(args: MarkThreadUnreadForOthersArgs): Promise<StatusOk>;
|
|
320
424
|
/**
|
|
321
425
|
* Marks every thread in a workspace or channel as read. Exactly one of
|
|
322
426
|
* `workspaceId` / `channelId` should be set.
|
|
427
|
+
*
|
|
428
|
+
* @param args - Either workspaceId or channelId (one is required).
|
|
429
|
+
* @param args.workspaceId - The workspace ID.
|
|
430
|
+
* @param args.channelId - The channel ID.
|
|
431
|
+
*
|
|
432
|
+
* @example
|
|
433
|
+
* ```typescript
|
|
434
|
+
* // Mark all in workspace
|
|
435
|
+
* await api.threads.markAllRead({ workspaceId: 123 })
|
|
436
|
+
*
|
|
437
|
+
* // Mark all in channel
|
|
438
|
+
* await api.threads.markAllRead({ channelId: '7YpL3oZ4kZ9vP7Q1tR2sX44' })
|
|
439
|
+
* ```
|
|
323
440
|
*/
|
|
324
441
|
markAllRead(args: {
|
|
325
442
|
workspaceId?: number;
|
|
326
443
|
channelId?: string;
|
|
327
444
|
}): Promise<StatusOk>;
|
|
445
|
+
/**
|
|
446
|
+
* Clears unread threads in a workspace.
|
|
447
|
+
*
|
|
448
|
+
* @param workspaceId - The workspace ID.
|
|
449
|
+
*/
|
|
328
450
|
clearUnread(workspaceId: number): Promise<StatusOk>;
|
|
329
451
|
/**
|
|
330
452
|
* Returns unread threads for a workspace, paired with the unread version
|
|
331
453
|
* counter and (optionally) the inbox unread count.
|
|
454
|
+
*
|
|
455
|
+
* @param workspaceId - The workspace ID.
|
|
456
|
+
* @returns Object containing the array of unread thread references, a version counter, and optionally the inbox unread count.
|
|
332
457
|
*/
|
|
333
458
|
getUnread(workspaceId: number): Promise<{
|
|
334
459
|
data: UnreadThread[];
|
|
335
460
|
version: number;
|
|
336
461
|
inboxUnread?: number | null;
|
|
337
462
|
}>;
|
|
463
|
+
/**
|
|
464
|
+
* Mutes a thread for a specified number of minutes.
|
|
465
|
+
* When muted, you will not get notified in your inbox about new comments.
|
|
466
|
+
*
|
|
467
|
+
* @param args - The arguments for muting a thread.
|
|
468
|
+
* @param args.id - The thread ID.
|
|
469
|
+
* @param args.minutes - Number of minutes to mute the thread.
|
|
470
|
+
* @returns The updated thread object.
|
|
471
|
+
*
|
|
472
|
+
* @example
|
|
473
|
+
* ```typescript
|
|
474
|
+
* const thread = await api.threads.muteThread({ id: '7YpL3oZ4kZ9vP7Q1tR2sX3z', minutes: 30 })
|
|
475
|
+
* ```
|
|
476
|
+
*/
|
|
338
477
|
muteThread(args: MuteThreadArgs): Promise<Thread>;
|
|
478
|
+
/**
|
|
479
|
+
* Unmutes a thread.
|
|
480
|
+
* You will start to see notifications in your inbox again when new comments are added.
|
|
481
|
+
*
|
|
482
|
+
* @param id - The thread ID.
|
|
483
|
+
* @returns The updated thread object.
|
|
484
|
+
*/
|
|
339
485
|
unmuteThread(id: string): Promise<Thread>;
|
|
486
|
+
/**
|
|
487
|
+
* Closes a thread by adding a comment with a close action.
|
|
488
|
+
*
|
|
489
|
+
* @param args - The arguments for closing a thread.
|
|
490
|
+
* @param args.id - The thread ID.
|
|
491
|
+
* @param args.content - The comment content.
|
|
492
|
+
* @param args.attachments - Optional array of {@link Attachment} objects.
|
|
493
|
+
* @param args.actions - Optional array of action objects.
|
|
494
|
+
* @param args.recipients - Optional array of user IDs to notify directly.
|
|
495
|
+
* @param args.groups - Optional array of custom group IDs to notify.
|
|
496
|
+
* @param args.directMentions - Optional array of user IDs that were @-mentioned in
|
|
497
|
+
* `content`.
|
|
498
|
+
* @param args.notifyAudience - Optional broader audience to notify in addition to
|
|
499
|
+
* `recipients` and `groups`. `'channel'` notifies everyone in the channel;
|
|
500
|
+
* `'thread'` notifies everyone who has interacted with the thread.
|
|
501
|
+
* @returns The created comment object.
|
|
502
|
+
*
|
|
503
|
+
* @example
|
|
504
|
+
* ```typescript
|
|
505
|
+
* const comment = await api.threads.closeThread({
|
|
506
|
+
* id: '7YpL3oZ4kZ9vP7Q1tR2sX3z',
|
|
507
|
+
* content: 'Closing this thread — resolved.',
|
|
508
|
+
* })
|
|
509
|
+
* ```
|
|
510
|
+
*/
|
|
340
511
|
closeThread(args: CloseThreadArgs): Promise<Comment>;
|
|
512
|
+
/**
|
|
513
|
+
* Reopens a thread by adding a comment with a reopen action.
|
|
514
|
+
*
|
|
515
|
+
* @param args - The arguments for reopening a thread.
|
|
516
|
+
* @param args.id - The thread ID.
|
|
517
|
+
* @param args.content - The comment content.
|
|
518
|
+
* @param args.attachments - Optional array of {@link Attachment} objects.
|
|
519
|
+
* @param args.actions - Optional array of action objects.
|
|
520
|
+
* @param args.recipients - Optional array of user IDs to notify directly.
|
|
521
|
+
* @param args.groups - Optional array of custom group IDs to notify.
|
|
522
|
+
* @param args.directMentions - Optional array of user IDs that were @-mentioned in
|
|
523
|
+
* `content`.
|
|
524
|
+
* @param args.notifyAudience - Optional broader audience to notify in addition to
|
|
525
|
+
* `recipients` and `groups`. `'channel'` notifies everyone in the channel;
|
|
526
|
+
* `'thread'` notifies everyone who has interacted with the thread.
|
|
527
|
+
* @returns The created comment object.
|
|
528
|
+
*
|
|
529
|
+
* @example
|
|
530
|
+
* ```typescript
|
|
531
|
+
* const comment = await api.threads.reopenThread({
|
|
532
|
+
* id: '7YpL3oZ4kZ9vP7Q1tR2sX3z',
|
|
533
|
+
* content: 'Reopening — need further discussion.',
|
|
534
|
+
* })
|
|
535
|
+
* ```
|
|
536
|
+
*/
|
|
341
537
|
reopenThread(args: ReopenThreadArgs): Promise<Comment>;
|
|
342
538
|
private addCommentWithAction;
|
|
343
539
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
}>;
|
|
@@ -7,38 +7,138 @@ import { BaseClient } from './base-client.js';
|
|
|
7
7
|
* rejects non-empty `name` and `channelIds` — set neither.
|
|
8
8
|
*/
|
|
9
9
|
export declare class WorkspaceUsersClient extends BaseClient {
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Returns a list of workspace user objects for the given workspace id.
|
|
12
|
+
*
|
|
13
|
+
* @param args - The arguments for getting workspace users.
|
|
14
|
+
* @param args.workspaceId - The workspace ID.
|
|
15
|
+
* @param args.archived - Optional flag to filter archived users.
|
|
16
|
+
* @returns An array of workspace user objects.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const users = await api.workspaceUsers.getWorkspaceUsers({ workspaceId: 123 })
|
|
21
|
+
* users.forEach(u => console.log(u.fullName, u.userType))
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
11
24
|
getWorkspaceUsers(args: GetWorkspaceUsersArgs): Promise<WorkspaceUser[]>;
|
|
12
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Returns a list of workspace user IDs for the given workspace id.
|
|
27
|
+
*
|
|
28
|
+
* @param workspaceId - The workspace ID.
|
|
29
|
+
* @returns An array of user IDs.
|
|
30
|
+
*/
|
|
13
31
|
getWorkspaceUserIds(workspaceId: number): Promise<number[]>;
|
|
14
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* Gets a user by id.
|
|
34
|
+
*
|
|
35
|
+
* @param args - The arguments for getting a user by ID.
|
|
36
|
+
* @param args.workspaceId - The workspace ID.
|
|
37
|
+
* @param args.userId - The user's ID.
|
|
38
|
+
* @returns The workspace user object.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* const user = await api.workspaceUsers.getUserById({ workspaceId: 123, userId: 456 })
|
|
43
|
+
* console.log(user.fullName, user.email)
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
15
46
|
getUserById(args: GetUserByIdArgs): Promise<WorkspaceUser>;
|
|
16
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* Gets a user by email.
|
|
49
|
+
*
|
|
50
|
+
* @param args - The arguments for getting a user by email.
|
|
51
|
+
* @param args.workspaceId - The workspace ID.
|
|
52
|
+
* @param args.email - The user's email.
|
|
53
|
+
* @returns The workspace user object.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* const user = await api.workspaceUsers.getUserByEmail({
|
|
58
|
+
* workspaceId: 123,
|
|
59
|
+
* email: 'user@example.com',
|
|
60
|
+
* })
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
17
63
|
getUserByEmail(args: GetUserByEmailArgs): Promise<WorkspaceUser>;
|
|
18
|
-
/**
|
|
64
|
+
/**
|
|
65
|
+
* Gets the user's info in the context of the workspace.
|
|
66
|
+
*
|
|
67
|
+
* @param args - The arguments for getting user info.
|
|
68
|
+
* @param args.workspaceId - The workspace ID.
|
|
69
|
+
* @param args.userId - The user's ID.
|
|
70
|
+
* @returns Information about the user in the workspace context.
|
|
71
|
+
*/
|
|
19
72
|
getUserInfo(args: GetUserInfoArgs): Promise<Record<string, unknown>>;
|
|
20
|
-
/**
|
|
73
|
+
/**
|
|
74
|
+
* Gets the user's local time (e.g., "2017-05-10 07:55:40").
|
|
75
|
+
*
|
|
76
|
+
* @param args - The arguments for getting user local time.
|
|
77
|
+
* @param args.workspaceId - The workspace ID.
|
|
78
|
+
* @param args.userId - The user's ID.
|
|
79
|
+
* @returns The user's local time as a string.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* const localTime = await api.workspaceUsers.getUserLocalTime({
|
|
84
|
+
* workspaceId: 123,
|
|
85
|
+
* userId: 456,
|
|
86
|
+
* })
|
|
87
|
+
* console.log('User local time:', localTime)
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
21
90
|
getUserLocalTime(args: GetUserLocalTimeArgs): Promise<string>;
|
|
22
|
-
/**
|
|
91
|
+
/**
|
|
92
|
+
* Adds a person to a workspace.
|
|
93
|
+
*
|
|
94
|
+
* @param args - The arguments for adding a user.
|
|
95
|
+
* @param args.workspaceId - The workspace ID.
|
|
96
|
+
* @param args.email - The user's email.
|
|
97
|
+
* @param args.userType - Optional user type (USER, GUEST, or ADMIN).
|
|
98
|
+
* @returns The created workspace user object.
|
|
99
|
+
*/
|
|
23
100
|
addUser(args: {
|
|
24
101
|
workspaceId: number;
|
|
25
102
|
email: string;
|
|
26
103
|
userType?: UserType;
|
|
27
104
|
}): Promise<WorkspaceUser>;
|
|
28
|
-
/**
|
|
105
|
+
/**
|
|
106
|
+
* Updates a person in a workspace.
|
|
107
|
+
*
|
|
108
|
+
* @param args - The arguments for updating a user.
|
|
109
|
+
* @param args.workspaceId - The workspace ID.
|
|
110
|
+
* @param args.userType - The user type (USER, GUEST, or ADMIN).
|
|
111
|
+
* @param args.email - Optional email of the user to update.
|
|
112
|
+
* @param args.userId - Optional user ID to update (use either email or userId).
|
|
113
|
+
* @returns The updated workspace user object.
|
|
114
|
+
*/
|
|
29
115
|
updateUser(args: {
|
|
30
116
|
workspaceId: number;
|
|
31
117
|
userType: UserType;
|
|
32
118
|
email?: string;
|
|
33
119
|
userId?: number;
|
|
34
120
|
}): Promise<WorkspaceUser>;
|
|
35
|
-
/**
|
|
121
|
+
/**
|
|
122
|
+
* Removes a person from a workspace.
|
|
123
|
+
*
|
|
124
|
+
* @param args - The arguments for removing a user.
|
|
125
|
+
* @param args.workspaceId - The workspace ID.
|
|
126
|
+
* @param args.email - Optional email of the user to remove.
|
|
127
|
+
* @param args.userId - Optional user ID to remove (use either email or userId).
|
|
128
|
+
*/
|
|
36
129
|
removeUser(args: {
|
|
37
130
|
workspaceId: number;
|
|
38
131
|
email?: string;
|
|
39
132
|
userId?: number;
|
|
40
133
|
}): Promise<void>;
|
|
41
|
-
/**
|
|
134
|
+
/**
|
|
135
|
+
* Sends a new workspace invitation to the selected user.
|
|
136
|
+
*
|
|
137
|
+
* @param args - The arguments for resending an invite.
|
|
138
|
+
* @param args.workspaceId - The workspace ID.
|
|
139
|
+
* @param args.email - The user's email.
|
|
140
|
+
* @param args.userId - Optional user ID.
|
|
141
|
+
*/
|
|
42
142
|
resendInvite(args: {
|
|
43
143
|
workspaceId: number;
|
|
44
144
|
email: string;
|