@doist/comms-sdk 3.3.1 → 3.4.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.
|
@@ -161,6 +161,42 @@ export class UsersClient extends BaseClient {
|
|
|
161
161
|
update(args) {
|
|
162
162
|
return this.post(`${ENDPOINT_USERS}/update`, args, UserSchema);
|
|
163
163
|
}
|
|
164
|
+
/**
|
|
165
|
+
* Sets the shared status of the session user, replacing any current one.
|
|
166
|
+
* The status belongs to the Todoist account, so it is shared with Todoist.
|
|
167
|
+
* Requires the `user:write` scope.
|
|
168
|
+
*
|
|
169
|
+
* @param args - The status to set.
|
|
170
|
+
* @param args.message - 1 to 80 characters once trimmed.
|
|
171
|
+
* @param args.emoji - Optional emoji.
|
|
172
|
+
* @param args.activeUntil - Optional expiry in the future (`Date` or ISO 8601 string).
|
|
173
|
+
* @param args.effects - Optional effects, e.g. `{ pauseNotifications: {} }` to hold back
|
|
174
|
+
* Comms notifications while the status is active.
|
|
175
|
+
* @returns The updated user object.
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* ```typescript
|
|
179
|
+
* await api.users.setStatus({
|
|
180
|
+
* message: 'Deep work',
|
|
181
|
+
* emoji: '🎯',
|
|
182
|
+
* activeUntil: new Date(Date.now() + 2 * 60 * 60 * 1000),
|
|
183
|
+
* effects: { pauseNotifications: {} },
|
|
184
|
+
* })
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
setStatus(args) {
|
|
188
|
+
const { activeUntil, ...rest } = args;
|
|
189
|
+
const payload = activeUntil instanceof Date ? { ...rest, activeUntil: activeUntil.toISOString() } : args;
|
|
190
|
+
return this.post(`${ENDPOINT_USERS}/set_status`, payload, UserSchema);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Clears the session user's shared status. Requires the `user:write` scope.
|
|
194
|
+
*
|
|
195
|
+
* @returns The updated user object.
|
|
196
|
+
*/
|
|
197
|
+
clearStatus() {
|
|
198
|
+
return this.post(`${ENDPOINT_USERS}/clear_status`, undefined, UserSchema);
|
|
199
|
+
}
|
|
164
200
|
/**
|
|
165
201
|
* Updates the user's password.
|
|
166
202
|
*
|
|
@@ -49,6 +49,19 @@ export const AttachmentSchema = z.object(attachmentShape).loose();
|
|
|
49
49
|
// this strips unknown keys so caller typos / off-spec fields are dropped instead
|
|
50
50
|
// of being forwarded on the wire. Use this for `*Args` request schemas.
|
|
51
51
|
export const RequestAttachmentSchema = z.object(attachmentShape);
|
|
52
|
+
// Shared user status. It lives on the Todoist account, so Comms, Todoist and
|
|
53
|
+
// automations all see the same one. `activeUntil` is an RFC 3339 string, and an
|
|
54
|
+
// expired status is returned as `null` rather than as an expired object.
|
|
55
|
+
export const UserStatusSchema = z.object({
|
|
56
|
+
message: z.string(),
|
|
57
|
+
emoji: z.string().nullable().optional(),
|
|
58
|
+
activeUntil: z.string().nullable().optional(),
|
|
59
|
+
effects: z
|
|
60
|
+
.object({
|
|
61
|
+
pauseNotifications: z.object({ scope: z.object({ mode: z.string() }) }).optional(),
|
|
62
|
+
})
|
|
63
|
+
.optional(),
|
|
64
|
+
});
|
|
52
65
|
// Fields shared by `User` and `WorkspaceUser`. Profile fields
|
|
53
66
|
// (`fullName`, `imageId`, avatar URLs) are sourced from Todoist-ID.
|
|
54
67
|
export const BaseUserSchema = z.object({
|
|
@@ -70,6 +83,7 @@ export const BaseUserSchema = z.object({
|
|
|
70
83
|
.optional(),
|
|
71
84
|
restricted: z.boolean().nullable().optional(),
|
|
72
85
|
setupPending: z.boolean().nullable().optional(),
|
|
86
|
+
status: UserStatusSchema.nullable().optional(),
|
|
73
87
|
});
|
|
74
88
|
// User entity from API.
|
|
75
89
|
export const UserSchema = BaseUserSchema.extend({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type User } from '../types/entities.js';
|
|
2
|
-
import type { UpdateUserArgs } from '../types/requests.js';
|
|
2
|
+
import type { SetStatusArgs, UpdateUserArgs } from '../types/requests.js';
|
|
3
3
|
import { BaseClient } from './base-client.js';
|
|
4
4
|
type EmailExistsResponse = {
|
|
5
5
|
exists: boolean;
|
|
@@ -159,6 +159,36 @@ export declare class UsersClient extends BaseClient {
|
|
|
159
159
|
* ```
|
|
160
160
|
*/
|
|
161
161
|
update(args: UpdateUserArgs): Promise<User>;
|
|
162
|
+
/**
|
|
163
|
+
* Sets the shared status of the session user, replacing any current one.
|
|
164
|
+
* The status belongs to the Todoist account, so it is shared with Todoist.
|
|
165
|
+
* Requires the `user:write` scope.
|
|
166
|
+
*
|
|
167
|
+
* @param args - The status to set.
|
|
168
|
+
* @param args.message - 1 to 80 characters once trimmed.
|
|
169
|
+
* @param args.emoji - Optional emoji.
|
|
170
|
+
* @param args.activeUntil - Optional expiry in the future (`Date` or ISO 8601 string).
|
|
171
|
+
* @param args.effects - Optional effects, e.g. `{ pauseNotifications: {} }` to hold back
|
|
172
|
+
* Comms notifications while the status is active.
|
|
173
|
+
* @returns The updated user object.
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```typescript
|
|
177
|
+
* await api.users.setStatus({
|
|
178
|
+
* message: 'Deep work',
|
|
179
|
+
* emoji: '🎯',
|
|
180
|
+
* activeUntil: new Date(Date.now() + 2 * 60 * 60 * 1000),
|
|
181
|
+
* effects: { pauseNotifications: {} },
|
|
182
|
+
* })
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
setStatus(args: SetStatusArgs): Promise<User>;
|
|
186
|
+
/**
|
|
187
|
+
* Clears the session user's shared status. Requires the `user:write` scope.
|
|
188
|
+
*
|
|
189
|
+
* @returns The updated user object.
|
|
190
|
+
*/
|
|
191
|
+
clearStatus(): Promise<User>;
|
|
162
192
|
/**
|
|
163
193
|
* Updates the user's password.
|
|
164
194
|
*
|
|
@@ -54,6 +54,19 @@ export declare const RequestAttachmentSchema: z.ZodObject<{
|
|
|
54
54
|
videoAutoPlay: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
55
55
|
}, z.core.$strip>;
|
|
56
56
|
export type RequestAttachment = z.infer<typeof RequestAttachmentSchema>;
|
|
57
|
+
export declare const UserStatusSchema: z.ZodObject<{
|
|
58
|
+
message: z.ZodString;
|
|
59
|
+
emoji: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
60
|
+
activeUntil: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
61
|
+
effects: z.ZodOptional<z.ZodObject<{
|
|
62
|
+
pauseNotifications: z.ZodOptional<z.ZodObject<{
|
|
63
|
+
scope: z.ZodObject<{
|
|
64
|
+
mode: z.ZodString;
|
|
65
|
+
}, z.core.$strip>;
|
|
66
|
+
}, z.core.$strip>>;
|
|
67
|
+
}, z.core.$strip>>;
|
|
68
|
+
}, z.core.$strip>;
|
|
69
|
+
export type UserStatus = z.infer<typeof UserStatusSchema>;
|
|
57
70
|
export declare const BaseUserSchema: z.ZodObject<{
|
|
58
71
|
id: z.ZodNumber;
|
|
59
72
|
fullName: z.ZodString;
|
|
@@ -70,6 +83,18 @@ export declare const BaseUserSchema: z.ZodObject<{
|
|
|
70
83
|
}, z.core.$strip>>>;
|
|
71
84
|
restricted: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
72
85
|
setupPending: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
86
|
+
status: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
87
|
+
message: z.ZodString;
|
|
88
|
+
emoji: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
89
|
+
activeUntil: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
90
|
+
effects: z.ZodOptional<z.ZodObject<{
|
|
91
|
+
pauseNotifications: z.ZodOptional<z.ZodObject<{
|
|
92
|
+
scope: z.ZodObject<{
|
|
93
|
+
mode: z.ZodString;
|
|
94
|
+
}, z.core.$strip>;
|
|
95
|
+
}, z.core.$strip>>;
|
|
96
|
+
}, z.core.$strip>>;
|
|
97
|
+
}, z.core.$strip>>>;
|
|
73
98
|
}, z.core.$strip>;
|
|
74
99
|
export declare const UserSchema: z.ZodObject<{
|
|
75
100
|
id: z.ZodNumber;
|
|
@@ -87,6 +112,18 @@ export declare const UserSchema: z.ZodObject<{
|
|
|
87
112
|
}, z.core.$strip>>>;
|
|
88
113
|
restricted: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
89
114
|
setupPending: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
115
|
+
status: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
116
|
+
message: z.ZodString;
|
|
117
|
+
emoji: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
118
|
+
activeUntil: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
119
|
+
effects: z.ZodOptional<z.ZodObject<{
|
|
120
|
+
pauseNotifications: z.ZodOptional<z.ZodObject<{
|
|
121
|
+
scope: z.ZodObject<{
|
|
122
|
+
mode: z.ZodString;
|
|
123
|
+
}, z.core.$strip>;
|
|
124
|
+
}, z.core.$strip>>;
|
|
125
|
+
}, z.core.$strip>>;
|
|
126
|
+
}, z.core.$strip>>>;
|
|
90
127
|
email: z.ZodEmail;
|
|
91
128
|
clientId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
92
129
|
cometChannel: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -1591,6 +1628,18 @@ export declare const WorkspaceUserSchema: z.ZodObject<{
|
|
|
1591
1628
|
}, z.core.$strip>>>;
|
|
1592
1629
|
restricted: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
1593
1630
|
setupPending: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
1631
|
+
status: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
1632
|
+
message: z.ZodString;
|
|
1633
|
+
emoji: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1634
|
+
activeUntil: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1635
|
+
effects: z.ZodOptional<z.ZodObject<{
|
|
1636
|
+
pauseNotifications: z.ZodOptional<z.ZodObject<{
|
|
1637
|
+
scope: z.ZodObject<{
|
|
1638
|
+
mode: z.ZodString;
|
|
1639
|
+
}, z.core.$strip>;
|
|
1640
|
+
}, z.core.$strip>>;
|
|
1641
|
+
}, z.core.$strip>>;
|
|
1642
|
+
}, z.core.$strip>>>;
|
|
1594
1643
|
email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1595
1644
|
userType: z.ZodEnum<{
|
|
1596
1645
|
USER: "USER";
|
|
@@ -1604,6 +1653,18 @@ export declare const WorkspaceUserSchema: z.ZodObject<{
|
|
|
1604
1653
|
}, z.core.$strip>;
|
|
1605
1654
|
export type WorkspaceUser = z.infer<typeof WorkspaceUserSchema>;
|
|
1606
1655
|
export declare const RestrictedWorkspaceUserSchema: z.ZodObject<{
|
|
1656
|
+
status: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
1657
|
+
message: z.ZodString;
|
|
1658
|
+
emoji: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1659
|
+
activeUntil: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1660
|
+
effects: z.ZodOptional<z.ZodObject<{
|
|
1661
|
+
pauseNotifications: z.ZodOptional<z.ZodObject<{
|
|
1662
|
+
scope: z.ZodObject<{
|
|
1663
|
+
mode: z.ZodString;
|
|
1664
|
+
}, z.core.$strip>;
|
|
1665
|
+
}, z.core.$strip>>;
|
|
1666
|
+
}, z.core.$strip>>;
|
|
1667
|
+
}, z.core.$strip>>>;
|
|
1607
1668
|
id: z.ZodNumber;
|
|
1608
1669
|
fullName: z.ZodString;
|
|
1609
1670
|
shortName: z.ZodString;
|
|
@@ -1637,6 +1698,18 @@ export declare const VisibleWorkspaceUserSchema: z.ZodUnion<readonly [z.ZodObjec
|
|
|
1637
1698
|
}, z.core.$strip>>>;
|
|
1638
1699
|
restricted: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
1639
1700
|
setupPending: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
1701
|
+
status: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
1702
|
+
message: z.ZodString;
|
|
1703
|
+
emoji: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1704
|
+
activeUntil: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1705
|
+
effects: z.ZodOptional<z.ZodObject<{
|
|
1706
|
+
pauseNotifications: z.ZodOptional<z.ZodObject<{
|
|
1707
|
+
scope: z.ZodObject<{
|
|
1708
|
+
mode: z.ZodString;
|
|
1709
|
+
}, z.core.$strip>;
|
|
1710
|
+
}, z.core.$strip>>;
|
|
1711
|
+
}, z.core.$strip>>;
|
|
1712
|
+
}, z.core.$strip>>>;
|
|
1640
1713
|
email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1641
1714
|
userType: z.ZodEnum<{
|
|
1642
1715
|
USER: "USER";
|
|
@@ -1648,6 +1721,18 @@ export declare const VisibleWorkspaceUserSchema: z.ZodUnion<readonly [z.ZodObjec
|
|
|
1648
1721
|
timeFormat: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1649
1722
|
version: z.ZodNumber;
|
|
1650
1723
|
}, z.core.$strip>, z.ZodObject<{
|
|
1724
|
+
status: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
1725
|
+
message: z.ZodString;
|
|
1726
|
+
emoji: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1727
|
+
activeUntil: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1728
|
+
effects: z.ZodOptional<z.ZodObject<{
|
|
1729
|
+
pauseNotifications: z.ZodOptional<z.ZodObject<{
|
|
1730
|
+
scope: z.ZodObject<{
|
|
1731
|
+
mode: z.ZodString;
|
|
1732
|
+
}, z.core.$strip>;
|
|
1733
|
+
}, z.core.$strip>>;
|
|
1734
|
+
}, z.core.$strip>>;
|
|
1735
|
+
}, z.core.$strip>>>;
|
|
1651
1736
|
id: z.ZodNumber;
|
|
1652
1737
|
fullName: z.ZodString;
|
|
1653
1738
|
shortName: z.ZodString;
|
|
@@ -185,6 +185,21 @@ export type UpdateUserArgs = {
|
|
|
185
185
|
/** Theme ID (0-12). String aliases like `'dark'` are also accepted. */
|
|
186
186
|
theme?: number | string;
|
|
187
187
|
};
|
|
188
|
+
export type SetStatusArgs = {
|
|
189
|
+
/** 1 to 80 characters once trimmed. */
|
|
190
|
+
message: string;
|
|
191
|
+
emoji?: string | null;
|
|
192
|
+
/** When the status ends. Must be in the future. A `Date` is sent as an ISO 8601 string. */
|
|
193
|
+
activeUntil?: Date | string | null;
|
|
194
|
+
effects?: {
|
|
195
|
+
/** Holds back Comms notifications while the status is active. They are not sent later. */
|
|
196
|
+
pauseNotifications?: {
|
|
197
|
+
scope?: {
|
|
198
|
+
mode: 'all';
|
|
199
|
+
};
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
};
|
|
188
203
|
type SearchArgsCommon = {
|
|
189
204
|
workspaceId: number;
|
|
190
205
|
channelIds?: string[];
|