@doist/todoist-api-typescript 6.10.0 → 7.1.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.
- package/README.md +24 -0
- package/dist/cjs/authentication.js +44 -48
- package/dist/cjs/consts/endpoints.js +1 -2
- package/dist/cjs/test-utils/test-defaults.js +0 -3
- package/dist/cjs/todoist-api.js +22 -35
- package/dist/cjs/types/entities.js +0 -12
- package/dist/cjs/utils/colors.js +9 -87
- package/dist/esm/authentication.js +45 -48
- package/dist/esm/consts/endpoints.js +0 -1
- package/dist/esm/test-utils/test-defaults.js +0 -3
- package/dist/esm/todoist-api.js +23 -36
- package/dist/esm/types/entities.js +0 -12
- package/dist/esm/utils/colors.js +8 -84
- package/dist/types/authentication.d.ts +0 -41
- package/dist/types/consts/endpoints.d.ts +0 -1
- package/dist/types/test-utils/test-defaults.d.ts +0 -1
- package/dist/types/todoist-api.d.ts +9 -6
- package/dist/types/types/entities.d.ts +1 -18
- package/dist/types/types/requests.d.ts +22 -48
- package/dist/types/types/sync/commands/index.d.ts +0 -4
- package/dist/types/utils/colors.d.ts +10 -140
- package/dist/types/utils/validators.d.ts +0 -2
- package/package.json +3 -1
|
@@ -44,7 +44,6 @@ export const ENDPOINT_SYNC_QUICK_ADD = ENDPOINT_REST_TASKS + '/quick';
|
|
|
44
44
|
export const ENDPOINT_SYNC = 'sync';
|
|
45
45
|
export const ENDPOINT_AUTHORIZATION = 'authorize';
|
|
46
46
|
export const ENDPOINT_GET_TOKEN = 'access_token';
|
|
47
|
-
export const ENDPOINT_REVOKE_TOKEN = 'access_tokens/revoke';
|
|
48
47
|
export const ENDPOINT_REVOKE = 'revoke';
|
|
49
48
|
// Workspace endpoints
|
|
50
49
|
export const ENDPOINT_WORKSPACE_INVITATIONS = 'workspaces/invitations';
|
|
@@ -23,7 +23,6 @@ const DEFAULT_USER_EMAIL = 'atestuser@doist.com';
|
|
|
23
23
|
const DEFAULT_COMMENT_ID = '4';
|
|
24
24
|
const DEFAULT_COMMENT_CONTENT = 'A comment';
|
|
25
25
|
const DEFAULT_COMMENT_REACTIONS = { '👍': ['1234', '5678'] };
|
|
26
|
-
const DEFAULT_NOTE_COUNT = 0;
|
|
27
26
|
const DEFAULT_CAN_ASSIGN_TASKS = true;
|
|
28
27
|
const DEFAULT_IS_ARCHIVED = false;
|
|
29
28
|
const DEFAULT_IS_DELETED = false;
|
|
@@ -73,7 +72,6 @@ export const DEFAULT_TASK = {
|
|
|
73
72
|
childOrder: DEFAULT_ORDER,
|
|
74
73
|
content: DEFAULT_TASK_CONTENT,
|
|
75
74
|
description: DEFAULT_TASK_DESCRIPTION,
|
|
76
|
-
noteCount: DEFAULT_NOTE_COUNT,
|
|
77
75
|
dayOrder: DEFAULT_ORDER,
|
|
78
76
|
isCollapsed: DEFAULT_IS_COLLAPSED,
|
|
79
77
|
isUncompletable: false,
|
|
@@ -105,7 +103,6 @@ export const TASK_WITH_OPTIONALS_AS_NULL = {
|
|
|
105
103
|
dayOrder: DEFAULT_ORDER,
|
|
106
104
|
isCollapsed: DEFAULT_IS_COLLAPSED,
|
|
107
105
|
isUncompletable: false,
|
|
108
|
-
noteCount: DEFAULT_NOTE_COUNT,
|
|
109
106
|
url: DEFAULT_TASK_URL,
|
|
110
107
|
};
|
|
111
108
|
export const DEFAULT_PROJECT = {
|
package/dist/esm/todoist-api.js
CHANGED
|
@@ -14,7 +14,7 @@ import { getSyncBaseUri, ENDPOINT_REST_TASKS, ENDPOINT_REST_TASKS_FILTER, ENDPOI
|
|
|
14
14
|
import { validateAttachment, validateComment, validateCommentArray, validateCurrentUser, validateLabel, validateLabelArray, validateProject, validateProjectArray, validateSection, validateSectionArray, validateTask, validateTaskArray, validateUserArray, validateProductivityStats, validateActivityEventArray, validateWorkspaceUserArray, validateWorkspaceInvitation, validateWorkspaceInvitationArray, validateWorkspacePlanDetails, validateJoinWorkspaceResult, validateWorkspaceArray, } from './utils/validators.js';
|
|
15
15
|
import { formatDateToYYYYMMDD } from './utils/url-helpers.js';
|
|
16
16
|
import { uploadMultipartFile } from './utils/multipart-upload.js';
|
|
17
|
-
import {
|
|
17
|
+
import { normalizeObjectEventTypeForApi, denormalizeObjectTypeFromApi, } from './utils/activity-helpers.js';
|
|
18
18
|
import { processTaskContent } from './utils/uncompletable-helpers.js';
|
|
19
19
|
import { z } from 'zod';
|
|
20
20
|
import { v4 as uuidv4 } from 'uuid';
|
|
@@ -59,24 +59,16 @@ export class TodoistApi {
|
|
|
59
59
|
*/
|
|
60
60
|
authToken,
|
|
61
61
|
/**
|
|
62
|
-
* Optional
|
|
62
|
+
* Optional configuration options
|
|
63
63
|
*/
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (typeof baseUrlOrOptions === 'string') {
|
|
68
|
-
// Legacy constructor: (authToken, baseUrl)
|
|
69
|
-
// eslint-disable-next-line no-console
|
|
70
|
-
console.warn('TodoistApi constructor with baseUrl as second parameter is deprecated. Use options object instead: new TodoistApi(token, { baseUrl, customFetch })');
|
|
71
|
-
this.syncApiBase = getSyncBaseUri(baseUrlOrOptions);
|
|
72
|
-
this.customFetch = undefined;
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
// New constructor: (authToken, options)
|
|
76
|
-
const options = baseUrlOrOptions || {};
|
|
77
|
-
this.syncApiBase = getSyncBaseUri(options.baseUrl);
|
|
78
|
-
this.customFetch = options.customFetch;
|
|
64
|
+
options) {
|
|
65
|
+
if (typeof options === 'string') {
|
|
66
|
+
throw new TypeError('Passing baseUrl as a string is no longer supported. Use an options object instead: new TodoistApi(token, { baseUrl })');
|
|
79
67
|
}
|
|
68
|
+
this.authToken = authToken;
|
|
69
|
+
const opts = options || {};
|
|
70
|
+
this.syncApiBase = getSyncBaseUri(opts.baseUrl);
|
|
71
|
+
this.customFetch = opts.customFetch;
|
|
80
72
|
}
|
|
81
73
|
/**
|
|
82
74
|
* Makes a request to the Sync API and handles error checking.
|
|
@@ -315,22 +307,28 @@ export class TodoistApi {
|
|
|
315
307
|
* Updates an existing task by its ID with the provided parameters.
|
|
316
308
|
*
|
|
317
309
|
* @param id - The unique identifier of the task to update.
|
|
318
|
-
* @param args - Update parameters such as content, priority, or due date.
|
|
310
|
+
* @param args - Update parameters such as content, priority, or due date. Pass
|
|
311
|
+
* `dueString: null` (or `"no date"`) to clear the due date.
|
|
319
312
|
* @param requestId - Optional custom identifier for the request.
|
|
320
313
|
* @returns A promise that resolves to the updated task.
|
|
321
314
|
*/
|
|
322
315
|
async updateTask(id, args, requestId) {
|
|
323
316
|
z.string().parse(id);
|
|
317
|
+
// Translate SDK alias for due-date clearing to Todoist's accepted payload value.
|
|
318
|
+
const normalizedArgs = args.dueString === null ? Object.assign(Object.assign({}, args), { dueString: 'no date' }) : args;
|
|
324
319
|
// Process content if both content and isUncompletable are provided
|
|
325
|
-
const processedArgs =
|
|
326
|
-
? Object.assign(Object.assign({},
|
|
320
|
+
const processedArgs = normalizedArgs.content && normalizedArgs.isUncompletable !== undefined
|
|
321
|
+
? Object.assign(Object.assign({}, normalizedArgs), { content: processTaskContent(normalizedArgs.content, normalizedArgs.isUncompletable) }) : normalizedArgs;
|
|
322
|
+
// Remap `order` → `childOrder` so snakeCaseKeys() produces `child_order`
|
|
323
|
+
const { order } = processedArgs, argsWithoutOrder = __rest(processedArgs, ["order"]);
|
|
324
|
+
const remappedArgs = order !== undefined ? Object.assign(Object.assign({}, argsWithoutOrder), { childOrder: order }) : argsWithoutOrder;
|
|
327
325
|
const response = await request({
|
|
328
326
|
httpMethod: 'POST',
|
|
329
327
|
baseUri: this.syncApiBase,
|
|
330
328
|
relativePath: generatePath(ENDPOINT_REST_TASKS, id),
|
|
331
329
|
apiToken: this.authToken,
|
|
332
330
|
customFetch: this.customFetch,
|
|
333
|
-
payload:
|
|
331
|
+
payload: remappedArgs,
|
|
334
332
|
requestId: requestId,
|
|
335
333
|
});
|
|
336
334
|
return validateTask(response.data);
|
|
@@ -342,7 +340,6 @@ export class TodoistApi {
|
|
|
342
340
|
* @param args - The paramets that should contain only one of projectId, sectionId, or parentId
|
|
343
341
|
* @param requestId - Optional custom identifier for the request.
|
|
344
342
|
* @returns - A promise that resolves to an array of the updated tasks.
|
|
345
|
-
* @deprecated Use `moveTask` for single task operations. This method uses the Sync API and may be removed in a future version.
|
|
346
343
|
*/
|
|
347
344
|
async moveTasks(ids, args, requestId) {
|
|
348
345
|
var _a;
|
|
@@ -1082,27 +1079,17 @@ export class TodoistApi {
|
|
|
1082
1079
|
* @returns A promise that resolves to a paginated response of activity events.
|
|
1083
1080
|
*/
|
|
1084
1081
|
async getActivityLogs(args = {}) {
|
|
1085
|
-
var _a, _b, _c;
|
|
1086
|
-
// Resolve dateFrom: prefer new param, fall back to deprecated `since`
|
|
1087
|
-
const rawDateFrom = (_a = args.dateFrom) !== null && _a !== void 0 ? _a : args.since;
|
|
1088
|
-
const rawDateTo = (_b = args.dateTo) !== null && _b !== void 0 ? _b : args.until;
|
|
1089
1082
|
// Convert Date objects to YYYY-MM-DD strings
|
|
1090
|
-
const dateFrom =
|
|
1091
|
-
const dateTo =
|
|
1092
|
-
// Destructure out
|
|
1093
|
-
const
|
|
1083
|
+
const dateFrom = args.dateFrom instanceof Date ? formatDateToYYYYMMDD(args.dateFrom) : args.dateFrom;
|
|
1084
|
+
const dateTo = args.dateTo instanceof Date ? formatDateToYYYYMMDD(args.dateTo) : args.dateTo;
|
|
1085
|
+
// Destructure out raw date, filter-type, and removed legacy fields so they don't leak into payload
|
|
1086
|
+
const _a = args, { dateFrom: _dateFrom, dateTo: _dateTo, objectEventTypes, objectType: _objectType, eventType: _eventType, since: _since, until: _until } = _a, rest = __rest(_a, ["dateFrom", "dateTo", "objectEventTypes", "objectType", "eventType", "since", "until"]);
|
|
1094
1087
|
// Build normalized objectEventTypes for the API
|
|
1095
1088
|
let normalizedObjectEventTypes;
|
|
1096
1089
|
if (objectEventTypes !== undefined) {
|
|
1097
1090
|
const arr = Array.isArray(objectEventTypes) ? objectEventTypes : [objectEventTypes];
|
|
1098
1091
|
normalizedObjectEventTypes = arr.map(normalizeObjectEventTypeForApi);
|
|
1099
1092
|
}
|
|
1100
|
-
else if (objectType !== undefined || eventType !== undefined) {
|
|
1101
|
-
// Synthesize combined filter from deprecated separate params
|
|
1102
|
-
const objPart = (_c = normalizeObjectTypeForApi(objectType)) !== null && _c !== void 0 ? _c : '';
|
|
1103
|
-
const evtPart = eventType !== null && eventType !== void 0 ? eventType : '';
|
|
1104
|
-
normalizedObjectEventTypes = [`${objPart}:${evtPart}`];
|
|
1105
|
-
}
|
|
1106
1093
|
const processedArgs = Object.assign(Object.assign(Object.assign(Object.assign({}, rest), (dateFrom !== undefined ? { dateFrom } : {})), (dateTo !== undefined ? { dateTo } : {})), (normalizedObjectEventTypes !== undefined
|
|
1107
1094
|
? { objectEventTypes: normalizedObjectEventTypes }
|
|
1108
1095
|
: {}));
|
|
@@ -54,10 +54,6 @@ export const TaskSchema = z
|
|
|
54
54
|
childOrder: z.number().int(),
|
|
55
55
|
content: z.string(),
|
|
56
56
|
description: z.string(),
|
|
57
|
-
/**
|
|
58
|
-
* @deprecated This field is deprecated and will always return 0. It will be removed in a future version. Do not use or rely on this field.
|
|
59
|
-
*/
|
|
60
|
-
noteCount: z.number().int(),
|
|
61
57
|
dayOrder: z.number().int(),
|
|
62
58
|
isCollapsed: z.boolean(),
|
|
63
59
|
isUncompletable: z.boolean().default(false),
|
|
@@ -282,20 +278,12 @@ export const ProductivityStatsSchema = z.object({
|
|
|
282
278
|
})),
|
|
283
279
|
});
|
|
284
280
|
export const ColorSchema = z.object({
|
|
285
|
-
/** @deprecated No longer used */
|
|
286
|
-
id: z.number(),
|
|
287
281
|
/** The key of the color (i.e. 'berry_red') */
|
|
288
282
|
key: z.string(),
|
|
289
283
|
/** The display name of the color (i.e. 'Berry Red') */
|
|
290
284
|
displayName: z.string(),
|
|
291
|
-
/** @deprecated Use {@link Color.displayName} instead */
|
|
292
|
-
name: z.string(),
|
|
293
285
|
/** The hex value of the color (i.e. '#b8255f') */
|
|
294
286
|
hexValue: z.string(),
|
|
295
|
-
/**
|
|
296
|
-
* @deprecated Use {@link Color.hexValue} instead
|
|
297
|
-
*/
|
|
298
|
-
value: z.string(),
|
|
299
287
|
});
|
|
300
288
|
/**
|
|
301
289
|
* Flexible object containing event-specific data.
|
package/dist/esm/utils/colors.js
CHANGED
|
@@ -1,162 +1,102 @@
|
|
|
1
1
|
export const berryRed = {
|
|
2
|
-
id: 30,
|
|
3
2
|
key: 'berry_red',
|
|
4
3
|
displayName: 'Berry Red',
|
|
5
|
-
name: 'Berry Red',
|
|
6
4
|
hexValue: '#b8255f',
|
|
7
|
-
value: '#b8255f',
|
|
8
5
|
};
|
|
9
6
|
export const red = {
|
|
10
|
-
id: 31,
|
|
11
7
|
key: 'red',
|
|
12
8
|
displayName: 'Red',
|
|
13
|
-
name: 'Red',
|
|
14
9
|
hexValue: '#db4035',
|
|
15
|
-
value: '#db4035',
|
|
16
10
|
};
|
|
17
11
|
export const orange = {
|
|
18
|
-
id: 32,
|
|
19
12
|
key: 'orange',
|
|
20
13
|
displayName: 'Orange',
|
|
21
|
-
name: 'Orange',
|
|
22
14
|
hexValue: '#ff9933',
|
|
23
|
-
value: '#ff9933',
|
|
24
15
|
};
|
|
25
16
|
export const yellow = {
|
|
26
|
-
id: 33,
|
|
27
17
|
key: 'yellow',
|
|
28
18
|
displayName: 'Yellow',
|
|
29
|
-
name: 'Yellow',
|
|
30
19
|
hexValue: '#fad000',
|
|
31
|
-
value: '#fad000',
|
|
32
20
|
};
|
|
33
21
|
export const oliveGreen = {
|
|
34
|
-
id: 34,
|
|
35
22
|
key: 'olive_green',
|
|
36
23
|
displayName: 'Olive Green',
|
|
37
|
-
name: 'Olive Green',
|
|
38
24
|
hexValue: '#afb83b',
|
|
39
|
-
value: '#afb83b',
|
|
40
25
|
};
|
|
41
26
|
export const limeGreen = {
|
|
42
|
-
id: 35,
|
|
43
27
|
key: 'lime_green',
|
|
44
28
|
displayName: 'Lime Green',
|
|
45
|
-
name: 'Lime Green',
|
|
46
29
|
hexValue: '#7ecc49',
|
|
47
|
-
value: '#7ecc49',
|
|
48
30
|
};
|
|
49
31
|
export const green = {
|
|
50
|
-
id: 36,
|
|
51
32
|
key: 'green',
|
|
52
33
|
displayName: 'Green',
|
|
53
|
-
name: 'Green',
|
|
54
34
|
hexValue: '#299438',
|
|
55
|
-
value: '#299438',
|
|
56
35
|
};
|
|
57
36
|
export const mintGreen = {
|
|
58
|
-
id: 37,
|
|
59
37
|
key: 'mint_green',
|
|
60
38
|
displayName: 'Mint Green',
|
|
61
|
-
name: 'Mint Green',
|
|
62
39
|
hexValue: '#6accbc',
|
|
63
|
-
value: '#6accbc',
|
|
64
40
|
};
|
|
65
|
-
export const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
displayName: 'Turquoise',
|
|
69
|
-
name: 'Turquoise',
|
|
41
|
+
export const teal = {
|
|
42
|
+
key: 'teal',
|
|
43
|
+
displayName: 'Teal',
|
|
70
44
|
hexValue: '#158fad',
|
|
71
|
-
value: '#158fad',
|
|
72
45
|
};
|
|
73
46
|
export const skyBlue = {
|
|
74
|
-
id: 39,
|
|
75
47
|
key: 'sky_blue',
|
|
76
48
|
displayName: 'Sky Blue',
|
|
77
|
-
name: 'Sky Blue',
|
|
78
49
|
hexValue: '#14aaf5',
|
|
79
|
-
value: '#14aaf5',
|
|
80
50
|
};
|
|
81
51
|
export const lightBlue = {
|
|
82
|
-
id: 40,
|
|
83
52
|
key: 'light_blue',
|
|
84
53
|
displayName: 'Light Blue',
|
|
85
|
-
name: 'Light Blue',
|
|
86
54
|
hexValue: '#96c3eb',
|
|
87
|
-
value: '#96c3eb',
|
|
88
55
|
};
|
|
89
56
|
export const blue = {
|
|
90
|
-
id: 41,
|
|
91
57
|
key: 'blue',
|
|
92
58
|
displayName: 'Blue',
|
|
93
|
-
name: 'Blue',
|
|
94
59
|
hexValue: '#4073ff',
|
|
95
|
-
value: '#4073ff',
|
|
96
60
|
};
|
|
97
61
|
export const grape = {
|
|
98
|
-
id: 42,
|
|
99
62
|
key: 'grape',
|
|
100
63
|
displayName: 'Grape',
|
|
101
|
-
name: 'Grape',
|
|
102
64
|
hexValue: '#884dff',
|
|
103
|
-
value: '#884dff',
|
|
104
65
|
};
|
|
105
66
|
export const violet = {
|
|
106
|
-
id: 43,
|
|
107
67
|
key: 'violet',
|
|
108
68
|
displayName: 'Violet',
|
|
109
|
-
name: 'Violet',
|
|
110
69
|
hexValue: '#af38eb',
|
|
111
|
-
value: '#af38eb',
|
|
112
70
|
};
|
|
113
71
|
export const lavender = {
|
|
114
|
-
id: 44,
|
|
115
72
|
key: 'lavender',
|
|
116
73
|
displayName: 'Lavender',
|
|
117
|
-
name: 'Lavender',
|
|
118
74
|
hexValue: '#eb96eb',
|
|
119
|
-
value: '#eb96eb',
|
|
120
75
|
};
|
|
121
76
|
export const magenta = {
|
|
122
|
-
id: 45,
|
|
123
77
|
key: 'magenta',
|
|
124
78
|
displayName: 'Magenta',
|
|
125
|
-
name: 'Magenta',
|
|
126
79
|
hexValue: '#e05194',
|
|
127
|
-
value: '#e05194',
|
|
128
80
|
};
|
|
129
81
|
export const salmon = {
|
|
130
|
-
id: 46,
|
|
131
82
|
key: 'salmon',
|
|
132
83
|
displayName: 'Salmon',
|
|
133
|
-
name: 'Salmon',
|
|
134
84
|
hexValue: '#ff8d85',
|
|
135
|
-
value: '#ff8d85',
|
|
136
85
|
};
|
|
137
86
|
export const charcoal = {
|
|
138
|
-
id: 47,
|
|
139
87
|
key: 'charcoal',
|
|
140
88
|
displayName: 'Charcoal',
|
|
141
|
-
name: 'Charcoal',
|
|
142
89
|
hexValue: '#808080',
|
|
143
|
-
value: '#808080',
|
|
144
90
|
};
|
|
145
|
-
export const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
displayName: 'Gray',
|
|
149
|
-
name: 'Gray',
|
|
91
|
+
export const grey = {
|
|
92
|
+
key: 'grey',
|
|
93
|
+
displayName: 'Grey',
|
|
150
94
|
hexValue: '#b8b8b8',
|
|
151
|
-
value: '#b8b8b8',
|
|
152
95
|
};
|
|
153
96
|
export const taupe = {
|
|
154
|
-
id: 49,
|
|
155
97
|
key: 'taupe',
|
|
156
98
|
displayName: 'Taupe',
|
|
157
|
-
name: 'Taupe',
|
|
158
99
|
hexValue: '#ccac93',
|
|
159
|
-
value: '#ccac93',
|
|
160
100
|
};
|
|
161
101
|
export const colors = [
|
|
162
102
|
berryRed,
|
|
@@ -167,7 +107,7 @@ export const colors = [
|
|
|
167
107
|
limeGreen,
|
|
168
108
|
green,
|
|
169
109
|
mintGreen,
|
|
170
|
-
|
|
110
|
+
teal,
|
|
171
111
|
skyBlue,
|
|
172
112
|
lightBlue,
|
|
173
113
|
blue,
|
|
@@ -177,26 +117,10 @@ export const colors = [
|
|
|
177
117
|
magenta,
|
|
178
118
|
salmon,
|
|
179
119
|
charcoal,
|
|
180
|
-
|
|
120
|
+
grey,
|
|
181
121
|
taupe,
|
|
182
122
|
];
|
|
183
123
|
export const defaultColor = charcoal;
|
|
184
|
-
/**
|
|
185
|
-
* @private
|
|
186
|
-
* @deprecated Use {@link getColorByKey} instead
|
|
187
|
-
*/
|
|
188
|
-
export function getColorById(colorId) {
|
|
189
|
-
const color = colors.find((color) => color.id === colorId);
|
|
190
|
-
return color !== null && color !== void 0 ? color : defaultColor;
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* @private
|
|
194
|
-
* @deprecated Use {@link getColorByKey} instead
|
|
195
|
-
*/
|
|
196
|
-
export function getColorByName(colorName) {
|
|
197
|
-
const color = colors.find((color) => color.name === colorName);
|
|
198
|
-
return color !== null && color !== void 0 ? color : defaultColor;
|
|
199
|
-
}
|
|
200
124
|
/**
|
|
201
125
|
* Retrieves a {@link Color} object by its key identifier.
|
|
202
126
|
*
|
|
@@ -28,15 +28,6 @@ export type AuthTokenResponse = {
|
|
|
28
28
|
accessToken: string;
|
|
29
29
|
tokenType: string;
|
|
30
30
|
};
|
|
31
|
-
/**
|
|
32
|
-
* Parameters required to revoke an access token.
|
|
33
|
-
* @see https://todoist.com/api/v1/docs#tag/Authorization/operation/revoke_access_token_api_api_v1_access_tokens_delete
|
|
34
|
-
*/
|
|
35
|
-
export type RevokeAuthTokenRequestArgs = {
|
|
36
|
-
clientId: string;
|
|
37
|
-
clientSecret: string;
|
|
38
|
-
accessToken: string;
|
|
39
|
-
};
|
|
40
31
|
/**
|
|
41
32
|
* Parameters required to revoke a token using RFC 7009 compliant endpoint.
|
|
42
33
|
* @see https://todoist.com/api/v1/docs#tag/Authorization
|
|
@@ -97,34 +88,7 @@ export declare function getAuthorizationUrl({ clientId, permissions, state, base
|
|
|
97
88
|
* @returns The access token response
|
|
98
89
|
* @throws {@link TodoistRequestError} If the token exchange fails
|
|
99
90
|
*/
|
|
100
|
-
/**
|
|
101
|
-
* @deprecated Use options object instead: getAuthToken(args, { baseUrl, customFetch })
|
|
102
|
-
*/
|
|
103
|
-
export declare function getAuthToken(args: AuthTokenRequestArgs, baseUrl: string): Promise<AuthTokenResponse>;
|
|
104
|
-
export declare function getAuthToken(args: AuthTokenRequestArgs): Promise<AuthTokenResponse>;
|
|
105
91
|
export declare function getAuthToken(args: AuthTokenRequestArgs, options?: AuthOptions): Promise<AuthTokenResponse>;
|
|
106
|
-
/**
|
|
107
|
-
* Revokes an access token, making it invalid for future use.
|
|
108
|
-
*
|
|
109
|
-
* @example
|
|
110
|
-
* ```typescript
|
|
111
|
-
* await revokeAuthToken({
|
|
112
|
-
* clientId: 'your-client-id',
|
|
113
|
-
* clientSecret: 'your-client-secret',
|
|
114
|
-
* accessToken: token
|
|
115
|
-
* })
|
|
116
|
-
* ```
|
|
117
|
-
*
|
|
118
|
-
* @deprecated Use {@link revokeToken} instead. This function uses a legacy endpoint that will be removed in a future version. The new function uses the RFC 7009 compliant endpoint.
|
|
119
|
-
* @returns True if revocation was successful
|
|
120
|
-
* @see https://todoist.com/api/v1/docs#tag/Authorization/operation/revoke_access_token_api_api_v1_access_tokens_delete
|
|
121
|
-
*/
|
|
122
|
-
/**
|
|
123
|
-
* @deprecated Use options object instead: revokeAuthToken(args, { baseUrl, customFetch })
|
|
124
|
-
*/
|
|
125
|
-
export declare function revokeAuthToken(args: RevokeAuthTokenRequestArgs, baseUrl: string): Promise<boolean>;
|
|
126
|
-
export declare function revokeAuthToken(args: RevokeAuthTokenRequestArgs): Promise<boolean>;
|
|
127
|
-
export declare function revokeAuthToken(args: RevokeAuthTokenRequestArgs, options?: AuthOptions): Promise<boolean>;
|
|
128
92
|
/**
|
|
129
93
|
* Revokes a token using the RFC 7009 OAuth 2.0 Token Revocation standard.
|
|
130
94
|
*
|
|
@@ -144,9 +108,4 @@ export declare function revokeAuthToken(args: RevokeAuthTokenRequestArgs, option
|
|
|
144
108
|
* @see https://datatracker.ietf.org/doc/html/rfc7009
|
|
145
109
|
* @see https://todoist.com/api/v1/docs#tag/Authorization
|
|
146
110
|
*/
|
|
147
|
-
/**
|
|
148
|
-
* @deprecated Use options object instead: revokeToken(args, { baseUrl, customFetch })
|
|
149
|
-
*/
|
|
150
|
-
export declare function revokeToken(args: RevokeTokenRequestArgs, baseUrl: string): Promise<boolean>;
|
|
151
|
-
export declare function revokeToken(args: RevokeTokenRequestArgs): Promise<boolean>;
|
|
152
111
|
export declare function revokeToken(args: RevokeTokenRequestArgs, options?: AuthOptions): Promise<boolean>;
|
|
@@ -35,7 +35,6 @@ export declare const ENDPOINT_SYNC_QUICK_ADD: string;
|
|
|
35
35
|
export declare const ENDPOINT_SYNC = "sync";
|
|
36
36
|
export declare const ENDPOINT_AUTHORIZATION = "authorize";
|
|
37
37
|
export declare const ENDPOINT_GET_TOKEN = "access_token";
|
|
38
|
-
export declare const ENDPOINT_REVOKE_TOKEN = "access_tokens/revoke";
|
|
39
38
|
export declare const ENDPOINT_REVOKE = "revoke";
|
|
40
39
|
export declare const ENDPOINT_WORKSPACE_INVITATIONS = "workspaces/invitations";
|
|
41
40
|
export declare const ENDPOINT_WORKSPACE_INVITATIONS_ALL = "workspaces/invitations/all";
|
|
@@ -40,12 +40,15 @@ export declare class TodoistApi {
|
|
|
40
40
|
private authToken;
|
|
41
41
|
private syncApiBase;
|
|
42
42
|
private customFetch?;
|
|
43
|
+
constructor(
|
|
43
44
|
/**
|
|
44
|
-
*
|
|
45
|
+
* Your Todoist API token.
|
|
45
46
|
*/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
authToken: string,
|
|
48
|
+
/**
|
|
49
|
+
* Optional configuration options
|
|
50
|
+
*/
|
|
51
|
+
options?: TodoistApiOptions);
|
|
49
52
|
/**
|
|
50
53
|
* Makes a request to the Sync API and handles error checking.
|
|
51
54
|
*
|
|
@@ -148,7 +151,8 @@ export declare class TodoistApi {
|
|
|
148
151
|
* Updates an existing task by its ID with the provided parameters.
|
|
149
152
|
*
|
|
150
153
|
* @param id - The unique identifier of the task to update.
|
|
151
|
-
* @param args - Update parameters such as content, priority, or due date.
|
|
154
|
+
* @param args - Update parameters such as content, priority, or due date. Pass
|
|
155
|
+
* `dueString: null` (or `"no date"`) to clear the due date.
|
|
152
156
|
* @param requestId - Optional custom identifier for the request.
|
|
153
157
|
* @returns A promise that resolves to the updated task.
|
|
154
158
|
*/
|
|
@@ -160,7 +164,6 @@ export declare class TodoistApi {
|
|
|
160
164
|
* @param args - The paramets that should contain only one of projectId, sectionId, or parentId
|
|
161
165
|
* @param requestId - Optional custom identifier for the request.
|
|
162
166
|
* @returns - A promise that resolves to an array of the updated tasks.
|
|
163
|
-
* @deprecated Use `moveTask` for single task operations. This method uses the Sync API and may be removed in a future version.
|
|
164
167
|
*/
|
|
165
168
|
moveTasks(ids: string[], args: MoveTaskArgs, requestId?: string): Promise<Task[]>;
|
|
166
169
|
/**
|
|
@@ -70,7 +70,6 @@ export declare const TaskSchema: z.ZodPipe<z.ZodObject<{
|
|
|
70
70
|
childOrder: z.ZodNumber;
|
|
71
71
|
content: z.ZodString;
|
|
72
72
|
description: z.ZodString;
|
|
73
|
-
noteCount: z.ZodNumber;
|
|
74
73
|
dayOrder: z.ZodNumber;
|
|
75
74
|
isCollapsed: z.ZodBoolean;
|
|
76
75
|
isUncompletable: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -111,7 +110,6 @@ export declare const TaskSchema: z.ZodPipe<z.ZodObject<{
|
|
|
111
110
|
childOrder: number;
|
|
112
111
|
content: string;
|
|
113
112
|
description: string;
|
|
114
|
-
noteCount: number;
|
|
115
113
|
dayOrder: number;
|
|
116
114
|
isCollapsed: boolean;
|
|
117
115
|
}, {
|
|
@@ -149,7 +147,6 @@ export declare const TaskSchema: z.ZodPipe<z.ZodObject<{
|
|
|
149
147
|
childOrder: number;
|
|
150
148
|
content: string;
|
|
151
149
|
description: string;
|
|
152
|
-
noteCount: number;
|
|
153
150
|
dayOrder: number;
|
|
154
151
|
isCollapsed: boolean;
|
|
155
152
|
isUncompletable: boolean;
|
|
@@ -686,33 +683,19 @@ export declare const ProductivityStatsSchema: z.ZodObject<{
|
|
|
686
683
|
*/
|
|
687
684
|
export type ProductivityStats = z.infer<typeof ProductivityStatsSchema>;
|
|
688
685
|
export declare const ColorSchema: z.ZodObject<{
|
|
689
|
-
id: z.ZodNumber;
|
|
690
686
|
key: z.ZodString;
|
|
691
687
|
displayName: z.ZodString;
|
|
692
|
-
name: z.ZodString;
|
|
693
688
|
hexValue: z.ZodString;
|
|
694
|
-
value: z.ZodString;
|
|
695
689
|
}, z.core.$strip>;
|
|
696
690
|
/**
|
|
697
691
|
* Represents a color in Todoist.
|
|
698
692
|
* @see https://todoist.com/api/v1/docs#tag/Colors
|
|
699
693
|
*/
|
|
700
694
|
export type Color = z.infer<typeof ColorSchema>;
|
|
701
|
-
/**
|
|
702
|
-
* @deprecated Use 'task' instead. This will be removed in the next major version.
|
|
703
|
-
*/
|
|
704
|
-
type DeprecatedItem = 'item';
|
|
705
|
-
/**
|
|
706
|
-
* @deprecated Use 'comment' instead. This will be removed in the next major version.
|
|
707
|
-
*/
|
|
708
|
-
type DeprecatedNote = 'note';
|
|
709
695
|
/**
|
|
710
696
|
* Type hints for known object types. Accepts any string for forward compatibility.
|
|
711
|
-
* Supports both modern naming ('task', 'comment') and legacy naming ('item', 'note').
|
|
712
|
-
*
|
|
713
|
-
* **Note**: The legacy values 'item' and 'note' are deprecated. Use 'task' and 'comment' instead.
|
|
714
697
|
*/
|
|
715
|
-
export type ActivityObjectType = 'task' | 'comment' | 'project' |
|
|
698
|
+
export type ActivityObjectType = 'task' | 'comment' | 'project' | (string & Record<string, never>);
|
|
716
699
|
/**
|
|
717
700
|
* Type hints for known event types. Accepts any string for forward compatibility.
|
|
718
701
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RequireAllOrNone, RequireOneOrNone, RequireExactlyOne } from 'type-fest';
|
|
2
2
|
import type { ColorKey } from '../utils/colors.js';
|
|
3
|
-
import type { ActivityEvent,
|
|
3
|
+
import type { ActivityEvent, ActivityObjectEventType, Comment, Duration, Label, PersonalProject, ProjectViewStyle, ProjectVisibility, Section, Task, User, WorkspaceProject } from './entities.js';
|
|
4
4
|
/**
|
|
5
5
|
* Arguments for creating a new task.
|
|
6
6
|
* @see https://todoist.com/api/v1/docs#tag/Tasks/operation/create_task_api_v1_tasks_post
|
|
@@ -115,9 +115,22 @@ export type UpdateTaskArgs = {
|
|
|
115
115
|
description?: string;
|
|
116
116
|
labels?: string[];
|
|
117
117
|
priority?: number;
|
|
118
|
-
|
|
118
|
+
/**
|
|
119
|
+
* Sort order of the task within its parent/project.
|
|
120
|
+
* Internally mapped to `child_order` in the API payload.
|
|
121
|
+
*/
|
|
122
|
+
order?: number;
|
|
123
|
+
/**
|
|
124
|
+
* Natural language due date.
|
|
125
|
+
* Use `"no date"` to clear a due date, or `null` as an SDK alias for the same behavior.
|
|
126
|
+
*/
|
|
127
|
+
dueString?: (string & {}) | 'no date' | null;
|
|
119
128
|
dueLang?: string | null;
|
|
120
129
|
assigneeId?: string | null;
|
|
130
|
+
/**
|
|
131
|
+
* Deadline date in `YYYY-MM-DD` format.
|
|
132
|
+
* Use `null` to clear a task deadline.
|
|
133
|
+
*/
|
|
121
134
|
deadlineDate?: string | null;
|
|
122
135
|
deadlineLang?: string | null;
|
|
123
136
|
isUncompletable?: boolean;
|
|
@@ -468,56 +481,17 @@ type GetActivityLogsArgsCommon = {
|
|
|
468
481
|
*/
|
|
469
482
|
dateTo?: Date | string;
|
|
470
483
|
};
|
|
471
|
-
|
|
472
|
-
type GetActivityLogsArgsLegacy = GetActivityLogsArgsCommon & {
|
|
473
|
-
/**
|
|
474
|
-
* Type of object to filter by (e.g., 'task', 'comment', 'project').
|
|
475
|
-
* Accepts both modern naming ('task', 'comment') and legacy naming ('item', 'note').
|
|
476
|
-
* @deprecated Use `objectEventTypes` instead.
|
|
477
|
-
*/
|
|
478
|
-
objectType?: ActivityObjectType;
|
|
479
|
-
/**
|
|
480
|
-
* Type of event to filter by (e.g., 'added', 'updated', 'deleted').
|
|
481
|
-
* @deprecated Use `objectEventTypes` instead.
|
|
482
|
-
*/
|
|
483
|
-
eventType?: ActivityEventType;
|
|
484
|
-
objectEventTypes?: never;
|
|
485
|
-
};
|
|
486
|
-
/** Use the modern combined objectEventTypes param. Cannot be combined with objectType/eventType. */
|
|
487
|
-
type GetActivityLogsArgsModern = GetActivityLogsArgsCommon & {
|
|
488
|
-
/**
|
|
489
|
-
* One or more combined object:event filter strings, e.g. `'task:added'`, `'task:'`, `':deleted'`.
|
|
490
|
-
* Accepts a single value or an array of values for multi-type filtering.
|
|
491
|
-
*/
|
|
484
|
+
export type GetActivityLogsArgs = GetActivityLogsArgsCommon & {
|
|
492
485
|
objectEventTypes?: ActivityObjectEventType | ActivityObjectEventType[];
|
|
486
|
+
/** @removed Use `objectEventTypes` instead. */
|
|
493
487
|
objectType?: never;
|
|
488
|
+
/** @removed Use `objectEventTypes` instead. */
|
|
494
489
|
eventType?: never;
|
|
490
|
+
/** @removed Use `dateFrom` instead. */
|
|
491
|
+
since?: never;
|
|
492
|
+
/** @removed Use `dateTo` instead. */
|
|
493
|
+
until?: never;
|
|
495
494
|
};
|
|
496
|
-
type GetActivityLogsArgsWithDate<TBase> = TBase & {
|
|
497
|
-
/**
|
|
498
|
-
* @deprecated Use `dateFrom` instead. Will be removed in the next major version.
|
|
499
|
-
*/
|
|
500
|
-
since?: Date;
|
|
501
|
-
/**
|
|
502
|
-
* @deprecated Use `dateTo` instead. Will be removed in the next major version.
|
|
503
|
-
*/
|
|
504
|
-
until?: Date;
|
|
505
|
-
};
|
|
506
|
-
/**
|
|
507
|
-
* @deprecated String dates (YYYY-MM-DD format) are deprecated. Use Date objects instead.
|
|
508
|
-
* This type will be removed in the next major version.
|
|
509
|
-
*/
|
|
510
|
-
type GetActivityLogsArgsWithString<TBase> = TBase & {
|
|
511
|
-
/**
|
|
512
|
-
* @deprecated Use `dateFrom` instead. Will be removed in the next major version.
|
|
513
|
-
*/
|
|
514
|
-
since?: string;
|
|
515
|
-
/**
|
|
516
|
-
* @deprecated Use `dateTo` instead. Will be removed in the next major version.
|
|
517
|
-
*/
|
|
518
|
-
until?: string;
|
|
519
|
-
};
|
|
520
|
-
export type GetActivityLogsArgs = GetActivityLogsArgsWithDate<GetActivityLogsArgsLegacy> | GetActivityLogsArgsWithString<GetActivityLogsArgsLegacy> | GetActivityLogsArgsWithDate<GetActivityLogsArgsModern> | GetActivityLogsArgsWithString<GetActivityLogsArgsModern>;
|
|
521
495
|
/**
|
|
522
496
|
* Response from retrieving activity logs.
|
|
523
497
|
*/
|
|
@@ -151,10 +151,6 @@ export type SyncCommand<Type extends SyncCommandType | string = string> = {
|
|
|
151
151
|
args: Type extends SyncCommandType ? SyncCommandsMap[Type] : Record<string, unknown>;
|
|
152
152
|
tempId?: string;
|
|
153
153
|
};
|
|
154
|
-
/**
|
|
155
|
-
* @deprecated Use `SyncCommand` instead.
|
|
156
|
-
*/
|
|
157
|
-
export type Command = SyncCommand<string>;
|
|
158
154
|
export * from './shared.js';
|
|
159
155
|
export * from './tasks.js';
|
|
160
156
|
export * from './projects.js';
|