@doist/todoist-api-typescript 6.9.0 → 7.0.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/rest-client.js +1 -1
- package/dist/cjs/test-utils/test-defaults.js +0 -3
- package/dist/cjs/todoist-api.js +27 -31
- package/dist/cjs/types/entities.js +0 -12
- package/dist/cjs/utils/activity-helpers.js +18 -0
- 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/rest-client.js +1 -1
- package/dist/esm/test-utils/test-defaults.js +0 -3
- package/dist/esm/todoist-api.js +28 -32
- package/dist/esm/types/entities.js +0 -12
- package/dist/esm/utils/activity-helpers.js +17 -0
- 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 +16 -18
- package/dist/types/types/requests.d.ts +22 -37
- package/dist/types/types/sync/commands/index.d.ts +0 -4
- package/dist/types/utils/activity-helpers.d.ts +8 -0
- package/dist/types/utils/colors.d.ts +10 -140
- package/dist/types/utils/validators.d.ts +0 -2
- package/package.json +3 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { request, isSuccess } from './rest-client.js';
|
|
2
2
|
import { v4 as uuid } from 'uuid';
|
|
3
3
|
import { TodoistRequestError } from './types/index.js';
|
|
4
|
-
import { getAuthBaseUri, getSyncBaseUri, ENDPOINT_AUTHORIZATION, ENDPOINT_GET_TOKEN,
|
|
4
|
+
import { getAuthBaseUri, getSyncBaseUri, ENDPOINT_AUTHORIZATION, ENDPOINT_GET_TOKEN, ENDPOINT_REVOKE, } from './consts/endpoints.js';
|
|
5
5
|
/**
|
|
6
6
|
* Creates a Basic Authentication header value from client credentials.
|
|
7
7
|
* @param clientId - The OAuth client ID
|
|
@@ -51,20 +51,28 @@ export function getAuthorizationUrl({ clientId, permissions, state, baseUrl, })
|
|
|
51
51
|
const scope = permissions.join(',');
|
|
52
52
|
return `${getAuthBaseUri(baseUrl)}${ENDPOINT_AUTHORIZATION}?client_id=${clientId}&scope=${scope}&state=${state}`;
|
|
53
53
|
}
|
|
54
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Exchanges an authorization code for an access token.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const { accessToken } = await getAuthToken({
|
|
60
|
+
* clientId: 'your-client-id',
|
|
61
|
+
* clientSecret: 'your-client-secret',
|
|
62
|
+
* code: authCode
|
|
63
|
+
* })
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* @returns The access token response
|
|
67
|
+
* @throws {@link TodoistRequestError} If the token exchange fails
|
|
68
|
+
*/
|
|
69
|
+
export async function getAuthToken(args, options) {
|
|
55
70
|
var _a;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (typeof baseUrlOrOptions === 'string') {
|
|
59
|
-
// Legacy signature: (args, baseUrl)
|
|
60
|
-
baseUrl = baseUrlOrOptions;
|
|
61
|
-
customFetch = undefined;
|
|
62
|
-
}
|
|
63
|
-
else if (baseUrlOrOptions) {
|
|
64
|
-
// New signature: (args, options)
|
|
65
|
-
baseUrl = baseUrlOrOptions.baseUrl;
|
|
66
|
-
customFetch = baseUrlOrOptions.customFetch;
|
|
71
|
+
if (typeof options === 'string') {
|
|
72
|
+
throw new TypeError('Passing baseUrl as a string is no longer supported. Use an options object instead: getAuthToken(args, { baseUrl })');
|
|
67
73
|
}
|
|
74
|
+
const baseUrl = options === null || options === void 0 ? void 0 : options.baseUrl;
|
|
75
|
+
const customFetch = options === null || options === void 0 ? void 0 : options.customFetch;
|
|
68
76
|
try {
|
|
69
77
|
const response = await request({
|
|
70
78
|
httpMethod: 'POST',
|
|
@@ -85,42 +93,31 @@ export async function getAuthToken(args, baseUrlOrOptions) {
|
|
|
85
93
|
throw new TodoistRequestError('Authentication token exchange failed.', err.httpStatusCode, err.responseData);
|
|
86
94
|
}
|
|
87
95
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
export async function revokeToken(args, baseUrlOrOptions) {
|
|
112
|
-
let baseUrl;
|
|
113
|
-
let customFetch;
|
|
114
|
-
if (typeof baseUrlOrOptions === 'string') {
|
|
115
|
-
// Legacy signature: (args, baseUrl)
|
|
116
|
-
baseUrl = baseUrlOrOptions;
|
|
117
|
-
customFetch = undefined;
|
|
118
|
-
}
|
|
119
|
-
else if (baseUrlOrOptions) {
|
|
120
|
-
// New signature: (args, options)
|
|
121
|
-
baseUrl = baseUrlOrOptions.baseUrl;
|
|
122
|
-
customFetch = baseUrlOrOptions.customFetch;
|
|
96
|
+
/**
|
|
97
|
+
* Revokes a token using the RFC 7009 OAuth 2.0 Token Revocation standard.
|
|
98
|
+
*
|
|
99
|
+
* This function uses HTTP Basic Authentication with client credentials and follows
|
|
100
|
+
* the RFC 7009 specification for token revocation.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```typescript
|
|
104
|
+
* await revokeToken({
|
|
105
|
+
* clientId: 'your-client-id',
|
|
106
|
+
* clientSecret: 'your-client-secret',
|
|
107
|
+
* token: 'access-token-to-revoke'
|
|
108
|
+
* })
|
|
109
|
+
* ```
|
|
110
|
+
*
|
|
111
|
+
* @returns True if revocation was successful
|
|
112
|
+
* @see https://datatracker.ietf.org/doc/html/rfc7009
|
|
113
|
+
* @see https://todoist.com/api/v1/docs#tag/Authorization
|
|
114
|
+
*/
|
|
115
|
+
export async function revokeToken(args, options) {
|
|
116
|
+
if (typeof options === 'string') {
|
|
117
|
+
throw new TypeError('Passing baseUrl as a string is no longer supported. Use an options object instead: revokeToken(args, { baseUrl })');
|
|
123
118
|
}
|
|
119
|
+
const baseUrl = options === null || options === void 0 ? void 0 : options.baseUrl;
|
|
120
|
+
const customFetch = options === null || options === void 0 ? void 0 : options.customFetch;
|
|
124
121
|
const { clientId, clientSecret, token } = args;
|
|
125
122
|
// Create Basic Auth header as per RFC 7009
|
|
126
123
|
const basicAuth = createBasicAuthHeader(clientId, clientSecret);
|
|
@@ -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';
|
package/dist/esm/rest-client.js
CHANGED
|
@@ -10,7 +10,7 @@ export function paramsSerializer(params) {
|
|
|
10
10
|
const value = params[key];
|
|
11
11
|
if (value != null) {
|
|
12
12
|
if (Array.isArray(value)) {
|
|
13
|
-
qs.append(key,
|
|
13
|
+
qs.append(key, JSON.stringify(value));
|
|
14
14
|
}
|
|
15
15
|
else if (typeof value === 'string' ||
|
|
16
16
|
typeof value === 'number' ||
|
|
@@ -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,15 +307,18 @@ 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;
|
|
327
322
|
const response = await request({
|
|
328
323
|
httpMethod: 'POST',
|
|
329
324
|
baseUri: this.syncApiBase,
|
|
@@ -342,7 +337,6 @@ export class TodoistApi {
|
|
|
342
337
|
* @param args - The paramets that should contain only one of projectId, sectionId, or parentId
|
|
343
338
|
* @param requestId - Optional custom identifier for the request.
|
|
344
339
|
* @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
340
|
*/
|
|
347
341
|
async moveTasks(ids, args, requestId) {
|
|
348
342
|
var _a;
|
|
@@ -1082,18 +1076,20 @@ export class TodoistApi {
|
|
|
1082
1076
|
* @returns A promise that resolves to a paginated response of activity events.
|
|
1083
1077
|
*/
|
|
1084
1078
|
async getActivityLogs(args = {}) {
|
|
1085
|
-
var _a, _b;
|
|
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
1079
|
// Convert Date objects to YYYY-MM-DD strings
|
|
1090
|
-
const dateFrom =
|
|
1091
|
-
const dateTo =
|
|
1092
|
-
// Destructure out
|
|
1093
|
-
const {
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1080
|
+
const dateFrom = args.dateFrom instanceof Date ? formatDateToYYYYMMDD(args.dateFrom) : args.dateFrom;
|
|
1081
|
+
const dateTo = args.dateTo instanceof Date ? formatDateToYYYYMMDD(args.dateTo) : args.dateTo;
|
|
1082
|
+
// Destructure out raw date, filter-type, and removed legacy fields so they don't leak into payload
|
|
1083
|
+
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"]);
|
|
1084
|
+
// Build normalized objectEventTypes for the API
|
|
1085
|
+
let normalizedObjectEventTypes;
|
|
1086
|
+
if (objectEventTypes !== undefined) {
|
|
1087
|
+
const arr = Array.isArray(objectEventTypes) ? objectEventTypes : [objectEventTypes];
|
|
1088
|
+
normalizedObjectEventTypes = arr.map(normalizeObjectEventTypeForApi);
|
|
1089
|
+
}
|
|
1090
|
+
const processedArgs = Object.assign(Object.assign(Object.assign(Object.assign({}, rest), (dateFrom !== undefined ? { dateFrom } : {})), (dateTo !== undefined ? { dateTo } : {})), (normalizedObjectEventTypes !== undefined
|
|
1091
|
+
? { objectEventTypes: normalizedObjectEventTypes }
|
|
1092
|
+
: {}));
|
|
1097
1093
|
const { data: { results, nextCursor }, } = await request({
|
|
1098
1094
|
httpMethod: 'GET',
|
|
1099
1095
|
baseUri: this.syncApiBase,
|
|
@@ -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.
|
|
@@ -34,3 +34,20 @@ export function denormalizeObjectTypeFromApi(objectType) {
|
|
|
34
34
|
return 'comment';
|
|
35
35
|
return objectType;
|
|
36
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Normalizes an `ActivityObjectEventType` filter string for the API,
|
|
39
|
+
* converting modern object type names to legacy API names.
|
|
40
|
+
* e.g. 'task:added' -> 'item:added', 'comment:' -> 'note:', ':deleted' -> ':deleted'
|
|
41
|
+
*
|
|
42
|
+
* @internal
|
|
43
|
+
*/
|
|
44
|
+
export function normalizeObjectEventTypeForApi(filter) {
|
|
45
|
+
var _a, _b;
|
|
46
|
+
const colonIndex = filter.indexOf(':');
|
|
47
|
+
if (colonIndex === -1) {
|
|
48
|
+
return (_a = normalizeObjectTypeForApi(filter)) !== null && _a !== void 0 ? _a : filter;
|
|
49
|
+
}
|
|
50
|
+
const objectPart = filter.slice(0, colonIndex);
|
|
51
|
+
const eventPart = filter.slice(colonIndex); // includes the colon
|
|
52
|
+
return `${(_b = normalizeObjectTypeForApi(objectPart)) !== null && _b !== void 0 ? _b : objectPart}${eventPart}`;
|
|
53
|
+
}
|
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
|
/**
|