@doist/todoist-api-typescript 7.3.0 → 7.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/README.md +2 -0
  2. package/dist/cjs/authentication.js +14 -4
  3. package/dist/cjs/consts/endpoints.js +11 -1
  4. package/dist/cjs/test-utils/asserts.js +1 -1
  5. package/dist/cjs/test-utils/test-defaults.js +33 -1
  6. package/dist/cjs/todoist-api.js +532 -88
  7. package/dist/cjs/{utils → transport}/fetch-with-retry.js +23 -71
  8. package/dist/cjs/{rest-client.js → transport/http-client.js} +6 -6
  9. package/dist/cjs/transport/http-dispatcher.js +72 -0
  10. package/dist/cjs/types/entities.js +11 -1
  11. package/dist/cjs/types/errors.js +9 -2
  12. package/dist/cjs/types/http.js +3 -1
  13. package/dist/cjs/types/requests.js +3 -0
  14. package/dist/cjs/types/sync/commands/labels.js +3 -0
  15. package/dist/cjs/types/sync/commands/shared.js +15 -0
  16. package/dist/cjs/types/sync/resources/reminders.js +2 -0
  17. package/dist/cjs/types/sync/user-preferences.js +27 -7
  18. package/dist/cjs/utils/multipart-upload.js +1 -1
  19. package/dist/cjs/utils/sanitization.js +7 -7
  20. package/dist/esm/authentication.js +10 -1
  21. package/dist/esm/consts/endpoints.js +9 -0
  22. package/dist/esm/test-utils/asserts.js +1 -1
  23. package/dist/esm/test-utils/test-defaults.js +32 -0
  24. package/dist/esm/todoist-api.js +467 -23
  25. package/dist/esm/{utils → transport}/fetch-with-retry.js +23 -38
  26. package/dist/esm/{rest-client.js → transport/http-client.js} +6 -6
  27. package/dist/esm/transport/http-dispatcher.js +35 -0
  28. package/dist/esm/types/entities.js +10 -0
  29. package/dist/esm/types/errors.js +7 -1
  30. package/dist/esm/types/http.js +3 -1
  31. package/dist/esm/types/requests.js +2 -1
  32. package/dist/esm/types/sync/commands/labels.js +2 -1
  33. package/dist/esm/types/sync/commands/shared.js +13 -1
  34. package/dist/esm/types/sync/resources/reminders.js +2 -0
  35. package/dist/esm/types/sync/user-preferences.js +23 -3
  36. package/dist/esm/utils/multipart-upload.js +1 -1
  37. package/dist/esm/utils/sanitization.js +7 -7
  38. package/dist/types/authentication.d.ts +5 -3
  39. package/dist/types/consts/endpoints.d.ts +9 -0
  40. package/dist/types/test-utils/test-defaults.d.ts +5 -1
  41. package/dist/types/todoist-api.d.ts +144 -3
  42. package/dist/types/{utils → transport}/fetch-with-retry.d.ts +1 -1
  43. package/dist/types/{rest-client.d.ts → transport/http-client.d.ts} +1 -1
  44. package/dist/types/transport/http-dispatcher.d.ts +3 -0
  45. package/dist/types/types/entities.d.ts +8 -1
  46. package/dist/types/types/errors.d.ts +4 -0
  47. package/dist/types/types/requests.d.ts +163 -1
  48. package/dist/types/types/sync/commands/labels.d.ts +5 -1
  49. package/dist/types/types/sync/commands/projects.d.ts +2 -2
  50. package/dist/types/types/sync/commands/reminders.d.ts +3 -2
  51. package/dist/types/types/sync/commands/shared.d.ts +10 -5
  52. package/dist/types/types/sync/resources/reminders.d.ts +4 -0
  53. package/dist/types/types/sync/resources/user.d.ts +2 -2
  54. package/dist/types/types/sync/user-preferences.d.ts +30 -4
  55. package/dist/types/utils/validators.d.ts +4 -0
  56. package/package.json +10 -17
  57. package/dist/cjs/test-utils/mocks.js +0 -3
  58. package/dist/esm/test-utils/mocks.js +0 -3
  59. package/dist/types/test-utils/mocks.d.ts +0 -0
@@ -10,6 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import { isNetworkError } from '../types/http.js';
13
+ import { getDefaultDispatcher } from './http-dispatcher.js';
13
14
  /**
14
15
  * Default retry configuration matching the original axios-retry behavior
15
16
  */
@@ -22,32 +23,11 @@ const DEFAULT_RETRY_CONFIG = {
22
23
  return retryNumber === 1 ? 0 : 500;
23
24
  },
24
25
  };
25
- /**
26
- * Cached HTTP agent to prevent creating multiple agents
27
- * null = not initialized, undefined = browser env, UndiciAgent = Node.js env
28
- */
29
- let httpAgent = null;
30
- /**
31
- * Gets the HTTP agent for Node.js environments or undefined for browser environments.
32
- * Uses dynamic import to avoid loading undici in browser environments.
33
- */
34
- async function getHttpAgent() {
35
- var _a;
36
- if (httpAgent === null) {
37
- if (typeof process !== 'undefined' && ((_a = process.versions) === null || _a === void 0 ? void 0 : _a.node)) {
38
- // We're in Node.js - dynamically import undici
39
- const { Agent } = await import('undici');
40
- httpAgent = new Agent({
41
- keepAliveTimeout: 1, // Close connections after 1ms of idle time
42
- keepAliveMaxTimeout: 1, // Maximum time to keep connections alive
43
- });
44
- }
45
- else {
46
- // We're in browser - no agent needed
47
- httpAgent = undefined;
48
- }
49
- }
50
- return httpAgent;
26
+ const TIMEOUT_ERROR_NAME = 'TimeoutError';
27
+ function createTimeoutError(timeoutMs) {
28
+ const error = new Error(`Request timeout after ${timeoutMs}ms`);
29
+ error.name = TIMEOUT_ERROR_NAME;
30
+ return error;
51
31
  }
52
32
  /**
53
33
  * Converts Headers object to a plain object
@@ -67,10 +47,14 @@ function createTimeoutSignal(timeoutMs, existingSignal) {
67
47
  const controller = new AbortController();
68
48
  // Timeout logic
69
49
  const timeoutId = setTimeout(() => {
70
- controller.abort(new Error(`Request timeout after ${timeoutMs}ms`));
50
+ controller.abort(createTimeoutError(timeoutMs));
71
51
  }, timeoutMs);
52
+ let abortHandler;
72
53
  function clear() {
73
54
  clearTimeout(timeoutId);
55
+ if (existingSignal && abortHandler) {
56
+ existingSignal.removeEventListener('abort', abortHandler);
57
+ }
74
58
  }
75
59
  // If there's an existing signal, forward its abort
76
60
  if (existingSignal) {
@@ -79,10 +63,11 @@ function createTimeoutSignal(timeoutMs, existingSignal) {
79
63
  controller.abort(existingSignal.reason);
80
64
  }
81
65
  else {
82
- existingSignal.addEventListener('abort', () => {
66
+ abortHandler = () => {
83
67
  clearTimeout(timeoutId);
84
68
  controller.abort(existingSignal.reason);
85
- }, { once: true });
69
+ };
70
+ existingSignal.addEventListener('abort', abortHandler, { once: true });
86
71
  }
87
72
  }
88
73
  // Clean up timeout when request completes
@@ -131,9 +116,13 @@ export async function fetchWithRetry(args) {
131
116
  fetchResponse = await customFetch(url, Object.assign(Object.assign({}, fetchOptions), { signal: requestSignal, timeout }));
132
117
  }
133
118
  else {
134
- const nativeResponse = await fetch(url, Object.assign(Object.assign({}, fetchOptions), { signal: requestSignal,
119
+ const dispatcher = await getDefaultDispatcher();
120
+ const nativeFetchOptions = Object.assign(Object.assign({}, fetchOptions), { signal: requestSignal });
121
+ if (dispatcher !== undefined) {
135
122
  // @ts-expect-error - dispatcher is a valid option for Node.js fetch but not in the TS types
136
- dispatcher: await getHttpAgent() }));
123
+ nativeFetchOptions.dispatcher = dispatcher;
124
+ }
125
+ const nativeResponse = await fetch(url, nativeFetchOptions);
137
126
  fetchResponse = convertResponseToCustomFetch(nativeResponse);
138
127
  }
139
128
  // Check if the response is successful
@@ -188,6 +177,9 @@ export async function fetchWithRetry(args) {
188
177
  };
189
178
  }
190
179
  catch (error) {
180
+ if (clearTimeoutFn) {
181
+ clearTimeoutFn();
182
+ }
191
183
  lastError = error;
192
184
  // Check if this error should trigger a retry
193
185
  const shouldRetry = attempt < config.retries && config.retryCondition(lastError);
@@ -197,9 +189,6 @@ export async function fetchWithRetry(args) {
197
189
  const networkError = lastError;
198
190
  networkError.isNetworkError = true;
199
191
  }
200
- if (clearTimeoutFn) {
201
- clearTimeoutFn();
202
- }
203
192
  throw lastError;
204
193
  }
205
194
  // Wait before retrying
@@ -207,10 +196,6 @@ export async function fetchWithRetry(args) {
207
196
  if (delay > 0) {
208
197
  await new Promise((resolve) => setTimeout(resolve, delay));
209
198
  }
210
- // Retry path – ensure this attempt's timeout is cleared before looping
211
- if (clearTimeoutFn) {
212
- clearTimeoutFn();
213
- }
214
199
  }
215
200
  }
216
201
  // This should never be reached, but just in case
@@ -1,14 +1,14 @@
1
- import { TodoistRequestError } from './types/errors.js';
2
- import { isNetworkError, isHttpError } from './types/http.js';
3
1
  import { v4 as uuidv4 } from 'uuid';
4
- import { API_BASE_URI } from './consts/endpoints.js';
5
- import { camelCaseKeys, snakeCaseKeys } from './utils/case-conversion.js';
6
- import { fetchWithRetry } from './utils/fetch-with-retry.js';
2
+ import { API_BASE_URI } from '../consts/endpoints.js';
3
+ import { TodoistRequestError } from '../types/errors.js';
4
+ import { isHttpError, isNetworkError } from '../types/http.js';
5
+ import { camelCaseKeys, snakeCaseKeys } from '../utils/case-conversion.js';
6
+ import { fetchWithRetry } from './fetch-with-retry.js';
7
7
  export function paramsSerializer(params) {
8
8
  const qs = new URLSearchParams();
9
9
  Object.keys(params).forEach((key) => {
10
10
  const value = params[key];
11
- if (value != null) {
11
+ if (value !== null && value !== undefined) {
12
12
  if (Array.isArray(value)) {
13
13
  qs.append(key, JSON.stringify(value));
14
14
  }
@@ -0,0 +1,35 @@
1
+ // Use effectively-disabled keep-alive so short-lived CLI processes do not stay
2
+ // open waiting on idle sockets. Undici requires positive values, so we use 1ms.
3
+ const KEEP_ALIVE_OPTIONS = {
4
+ keepAliveTimeout: 1,
5
+ keepAliveMaxTimeout: 1,
6
+ };
7
+ let defaultDispatcherPromise;
8
+ export function getDefaultDispatcher() {
9
+ if (!isNodeEnvironment()) {
10
+ return Promise.resolve(undefined);
11
+ }
12
+ if (!defaultDispatcherPromise) {
13
+ defaultDispatcherPromise = createDefaultDispatcher().catch((error) => {
14
+ defaultDispatcherPromise = undefined;
15
+ throw error;
16
+ });
17
+ }
18
+ return defaultDispatcherPromise;
19
+ }
20
+ export async function resetDefaultDispatcherForTests() {
21
+ if (!defaultDispatcherPromise) {
22
+ return;
23
+ }
24
+ const dispatcherPromise = defaultDispatcherPromise;
25
+ defaultDispatcherPromise = undefined;
26
+ await dispatcherPromise.then((dispatcher) => dispatcher.close(), () => undefined);
27
+ }
28
+ async function createDefaultDispatcher() {
29
+ const { EnvHttpProxyAgent } = await import('undici');
30
+ return new EnvHttpProxyAgent(KEEP_ALIVE_OPTIONS);
31
+ }
32
+ function isNodeEnvironment() {
33
+ var _a;
34
+ return typeof process !== 'undefined' && Boolean((_a = process.versions) === null || _a === void 0 ? void 0 : _a.node);
35
+ }
@@ -114,6 +114,8 @@ export const WorkspaceProjectSchema = BaseProjectSchema.extend({
114
114
  }).transform((data) => {
115
115
  return Object.assign(Object.assign({}, data), { url: getProjectUrl(data.id, data.name) });
116
116
  });
117
+ /** Available project view styles. */
118
+ export const PROJECT_VIEW_STYLES = ['list', 'board', 'calendar'];
117
119
  export const SectionSchema = z
118
120
  .object({
119
121
  id: z.string(),
@@ -317,6 +319,14 @@ export const ActivityEventSchema = z
317
319
  extraData: ActivityEventExtraDataSchema,
318
320
  })
319
321
  .catchall(z.any());
322
+ /** Available project collaborator roles. */
323
+ export const COLLABORATOR_ROLES = [
324
+ 'CREATOR',
325
+ 'ADMIN',
326
+ 'READ_WRITE',
327
+ 'EDIT_ONLY',
328
+ 'COMPLETE_ONLY',
329
+ ];
320
330
  /**
321
331
  * Available workspace roles.
322
332
  */
@@ -1,7 +1,6 @@
1
1
  import { CustomError } from 'ts-custom-error';
2
2
  const authenticationErrorCodes = [401, 403];
3
3
  export class TodoistRequestError extends CustomError {
4
- // eslint-disable-next-line max-params
5
4
  constructor(message, httpStatusCode, responseData) {
6
5
  super(message);
7
6
  this.message = message;
@@ -16,3 +15,10 @@ export class TodoistRequestError extends CustomError {
16
15
  Object.defineProperty(this, 'name', { value: 'TodoistRequestError' });
17
16
  }
18
17
  }
18
+ export class TodoistArgumentError extends CustomError {
19
+ constructor(message) {
20
+ super(message);
21
+ this.message = message;
22
+ Object.defineProperty(this, 'name', { value: 'TodoistArgumentError' });
23
+ }
24
+ }
@@ -2,12 +2,14 @@
2
2
  * Type guard to check if an error is a network error
3
3
  */
4
4
  export function isNetworkError(error) {
5
- // Network errors in fetch are typically TypeError with specific messages
5
+ // Network errors in fetch are typically TypeError with specific messages.
6
+ // Timeout errors are created by fetch-with-retry with the TimeoutError name.
6
7
  return ((error instanceof TypeError &&
7
8
  (error.message.includes('fetch') ||
8
9
  error.message.includes('network') ||
9
10
  error.message.includes('Failed to fetch') ||
10
11
  error.message.includes('NetworkError'))) ||
12
+ error.name === 'TimeoutError' ||
11
13
  error.isNetworkError === true);
12
14
  }
13
15
  /**
@@ -1 +1,2 @@
1
- export {};
1
+ /** Available reminder delivery services. */
2
+ export const REMINDER_DELIVERY_SERVICES = ['email', 'push'];
@@ -1 +1,2 @@
1
- export {};
1
+ /** Available label delete cascade modes. */
2
+ export const LABEL_DELETE_CASCADE_MODES = ['none', 'all'];
@@ -1,4 +1,16 @@
1
1
  /**
2
2
  * Shared types used across multiple Sync API command argument types.
3
3
  */
4
- export {};
4
+ /** Available project workflow statuses. */
5
+ export const PROJECT_STATUSES = [
6
+ 'PLANNED',
7
+ 'IN_PROGRESS',
8
+ 'PAUSED',
9
+ 'COMPLETED',
10
+ 'CANCELED',
11
+ ];
12
+ export { COLLABORATOR_ROLES } from '../../entities.js';
13
+ /** Available reminder notification services. */
14
+ export const REMINDER_SERVICES = ['default', 'email', 'mobile', 'push', 'no_default'];
15
+ /** Available workspace project sort orders. */
16
+ export const WORKSPACE_PROJECT_SORT_ORDERS = ['MANUAL', 'A_TO_Z', 'Z_TO_A'];
@@ -20,11 +20,13 @@ export const LocationReminderSchema = ReminderBaseSchema.extend({
20
20
  export const AbsoluteReminderSchema = ReminderBaseSchema.extend({
21
21
  type: z.literal('absolute'),
22
22
  due: DueDateSchema,
23
+ isUrgent: z.boolean().optional(),
23
24
  }).passthrough();
24
25
  export const RelativeReminderSchema = ReminderBaseSchema.extend({
25
26
  type: z.literal('relative'),
26
27
  minuteOffset: z.number().int(),
27
28
  due: DueDateSchema.optional(),
29
+ isUrgent: z.boolean().optional(),
28
30
  }).passthrough();
29
31
  export const ReminderSchema = z.discriminatedUnion('type', [
30
32
  LocationReminderSchema,
@@ -1,7 +1,27 @@
1
1
  import { z } from 'zod';
2
- const DATE_FORMAT_FROM_API = { 0: 'DD/MM/YYYY', 1: 'MM/DD/YYYY' };
3
- const TIME_FORMAT_FROM_API = { 0: '24h', 1: '12h' };
4
- const DAY_OF_WEEK_FROM_API = {
2
+ /** Available date format options. */
3
+ export const DATE_FORMATS = ['DD/MM/YYYY', 'MM/DD/YYYY'];
4
+ /** Available time format options. */
5
+ export const TIME_FORMATS = ['24h', '12h'];
6
+ /** Available days of the week. */
7
+ export const DAYS_OF_WEEK = [
8
+ 'Monday',
9
+ 'Tuesday',
10
+ 'Wednesday',
11
+ 'Thursday',
12
+ 'Friday',
13
+ 'Saturday',
14
+ 'Sunday',
15
+ ];
16
+ export const DATE_FORMAT_FROM_API = {
17
+ 0: 'DD/MM/YYYY',
18
+ 1: 'MM/DD/YYYY',
19
+ };
20
+ export const TIME_FORMAT_FROM_API = {
21
+ 0: '24h',
22
+ 1: '12h',
23
+ };
24
+ export const DAY_OF_WEEK_FROM_API = {
5
25
  1: 'Monday',
6
26
  2: 'Tuesday',
7
27
  3: 'Wednesday',
@@ -1,4 +1,4 @@
1
- import { fetchWithRetry } from './fetch-with-retry.js';
1
+ import { fetchWithRetry } from '../transport/fetch-with-retry.js';
2
2
  /**
3
3
  * Helper function to determine content-type from filename extension.
4
4
  * @param fileName - The filename to analyze
@@ -14,7 +14,7 @@ function removeStyleFormatting(input) {
14
14
  if (!input.includes('!') && !input.includes('*') && !input.includes('_')) {
15
15
  return input;
16
16
  }
17
- function removeMarkdown(match, prefix, text) {
17
+ function removeMarkdown(_match, prefix, text) {
18
18
  return `${prefix}${text}`;
19
19
  }
20
20
  input = input.replace(BOLD_ITALIC_FORMAT, removeMarkdown);
@@ -23,7 +23,7 @@ function removeStyleFormatting(input) {
23
23
  return input;
24
24
  }
25
25
  function removeCodeFormatting(input) {
26
- function removeMarkdown(match, text) {
26
+ function removeMarkdown(_match, text) {
27
27
  return text;
28
28
  }
29
29
  input = input.replace(CODE_BLOCK_FORMAT, removeMarkdown);
@@ -43,7 +43,7 @@ function removeMarkdownLinks(input) {
43
43
  if (!input.includes('[') || !input.includes(']')) {
44
44
  return input;
45
45
  }
46
- function removeMarkdown(match, text) {
46
+ function removeMarkdown(_match, text) {
47
47
  return text;
48
48
  }
49
49
  return input.replace(MARKDOWN_LINK, removeMarkdown);
@@ -52,20 +52,20 @@ function removeTodoistLinks(input) {
52
52
  if (!input.includes('(') || !input.includes(')')) {
53
53
  return input;
54
54
  }
55
- function removeMarkdown(match, url, text) {
55
+ function removeMarkdown(_match, _url, text) {
56
56
  return text;
57
57
  }
58
58
  return input.replace(TODOIST_LINK, removeMarkdown);
59
59
  }
60
60
  function removeAppLinks(input) {
61
61
  if (input.includes('gmail')) {
62
- input = input.replace(GMAIL_LINK, (match, id, text) => text);
62
+ input = input.replace(GMAIL_LINK, (_match, _id, text) => text);
63
63
  }
64
64
  if (input.includes('outlook')) {
65
- input = input.replace(OUTLOOK_LINK, (match, id, text) => text);
65
+ input = input.replace(OUTLOOK_LINK, (_match, _id, text) => text);
66
66
  }
67
67
  if (input.includes('thunderbird')) {
68
- input = input.replace(THUNDERBIRD_LINK, (match, text) => text);
68
+ input = input.replace(THUNDERBIRD_LINK, (_match, text) => text);
69
69
  }
70
70
  return input;
71
71
  }
@@ -6,11 +6,13 @@ export type AuthOptions = {
6
6
  baseUrl?: string;
7
7
  customFetch?: CustomFetch;
8
8
  };
9
+ /** Available OAuth2 permission scopes. */
10
+ export declare const PERMISSIONS: readonly ["task:add", "data:read", "data:read_write", "data:delete", "project:delete", "backups:read"];
9
11
  /**
10
- * Permission scopes that can be requested during OAuth2 authorization.
12
+ * Permission scope that can be requested during OAuth2 authorization.
11
13
  * @see {@link https://todoist.com/api/v1/docs#tag/Authorization}
12
14
  */
13
- export type Permission = 'task:add' | 'data:read' | 'data:read_write' | 'data:delete' | 'project:delete' | 'backups:read';
15
+ export type Permission = (typeof PERMISSIONS)[number];
14
16
  /**
15
17
  * Parameters required to exchange an authorization code for an access token.
16
18
  * @see https://todoist.com/api/v1/docs#tag/Authorization/OAuth
@@ -69,7 +71,7 @@ export declare function getAuthStateParameter(): string;
69
71
  */
70
72
  export declare function getAuthorizationUrl({ clientId, permissions, state, baseUrl, }: {
71
73
  clientId: string;
72
- permissions: Permission[];
74
+ permissions: readonly Permission[];
73
75
  state: string;
74
76
  baseUrl?: string;
75
77
  }): string;
@@ -16,6 +16,8 @@ export declare const ENDPOINT_REST_LABELS_SHARED: string;
16
16
  export declare const ENDPOINT_REST_LABELS_SHARED_RENAME: string;
17
17
  export declare const ENDPOINT_REST_LABELS_SHARED_REMOVE: string;
18
18
  export declare const ENDPOINT_REST_COMMENTS = "comments";
19
+ export declare const ENDPOINT_REST_REMINDERS = "reminders";
20
+ export declare const ENDPOINT_REST_LOCATION_REMINDERS = "location_reminders";
19
21
  export declare const ENDPOINT_REST_TASK_CLOSE = "close";
20
22
  export declare const ENDPOINT_REST_TASK_REOPEN = "reopen";
21
23
  export declare const ENDPOINT_REST_TASK_MOVE = "move";
@@ -29,6 +31,12 @@ export declare const ENDPOINT_REST_ACTIVITIES = "activities";
29
31
  export declare const ENDPOINT_REST_UPLOADS = "uploads";
30
32
  export declare const PROJECT_ARCHIVE = "archive";
31
33
  export declare const PROJECT_UNARCHIVE = "unarchive";
34
+ export declare const ENDPOINT_REST_PROJECTS_ARCHIVED_COUNT: string;
35
+ export declare const ENDPOINT_REST_PROJECTS_PERMISSIONS: string;
36
+ export declare const ENDPOINT_REST_PROJECT_FULL = "full";
37
+ export declare const ENDPOINT_REST_PROJECT_JOIN = "join";
38
+ export declare const SECTION_ARCHIVE = "archive";
39
+ export declare const SECTION_UNARCHIVE = "unarchive";
32
40
  export declare const ENDPOINT_REST_PROJECTS_MOVE_TO_WORKSPACE: string;
33
41
  export declare const ENDPOINT_REST_PROJECTS_MOVE_TO_PERSONAL: string;
34
42
  export declare const ENDPOINT_SYNC_QUICK_ADD: string;
@@ -36,6 +44,7 @@ export declare const ENDPOINT_SYNC = "sync";
36
44
  export declare const ENDPOINT_AUTHORIZATION = "authorize";
37
45
  export declare const ENDPOINT_GET_TOKEN = "access_token";
38
46
  export declare const ENDPOINT_REVOKE = "revoke";
47
+ export declare const ENDPOINT_REST_WORKSPACES = "workspaces";
39
48
  export declare const ENDPOINT_WORKSPACE_INVITATIONS = "workspaces/invitations";
40
49
  export declare const ENDPOINT_WORKSPACE_INVITATIONS_ALL = "workspaces/invitations/all";
41
50
  export declare const ENDPOINT_WORKSPACE_INVITATIONS_DELETE = "workspaces/invitations/delete";
@@ -1,4 +1,4 @@
1
- import { Label, Section, Task, User, Attachment, Duration, Deadline, RawComment, PersonalProject } from '../types/index.js';
1
+ import { Label, Section, Task, User, Attachment, Duration, Deadline, RawComment, PersonalProject, Reminder } from '../types/index.js';
2
2
  export declare const DEFAULT_TASK_ID = "1234";
3
3
  export declare const DEFAULT_TASK_CONTENT = "This is a task";
4
4
  export declare const DEFAULT_TASK_DESCRIPTION = "A description";
@@ -148,6 +148,10 @@ export declare const DEFAULT_COMMENT: {
148
148
  isDeleted: boolean;
149
149
  projectId?: string | undefined;
150
150
  };
151
+ export declare const DEFAULT_REMINDER_ID = "6XGgmFQrx44wfGHr";
152
+ export declare const DEFAULT_RELATIVE_REMINDER: Reminder;
153
+ export declare const DEFAULT_ABSOLUTE_REMINDER: Reminder;
154
+ export declare const DEFAULT_LOCATION_REMINDER: Reminder;
151
155
  export declare const INVALID_COMMENT: {
152
156
  isDeleted: string;
153
157
  id: string;
@@ -1,6 +1,7 @@
1
1
  import { Attachment, PersonalProject, WorkspaceProject, Label, Section, Comment, Task, CurrentUser, ProductivityStats, WorkspaceInvitation, WorkspacePlanDetails, JoinWorkspaceResult, Workspace } from './types/entities.js';
2
- import { AddCommentArgs, AddLabelArgs, AddProjectArgs, AddSectionArgs, AddTaskArgs, GetProjectCommentsArgs, GetTaskCommentsArgs, GetTasksArgs, GetTasksByFilterArgs, UpdateCommentArgs, UpdateLabelArgs, UpdateProjectArgs, UpdateSectionArgs, UpdateTaskArgs, QuickAddTaskArgs, GetSharedLabelsArgs, RenameSharedLabelArgs, RemoveSharedLabelArgs, GetProjectsArgs, SearchProjectsArgs, GetProjectCollaboratorsArgs, GetLabelsArgs, SearchLabelsArgs, GetLabelsResponse, GetTasksResponse, GetProjectsResponse, GetProjectCollaboratorsResponse, GetSectionsArgs, SearchSectionsArgs, GetSectionsResponse, GetSharedLabelsResponse, GetCommentsResponse, type MoveTaskArgs, GetCompletedTasksByCompletionDateArgs, GetCompletedTasksByDueDateArgs, GetCompletedTasksResponse, GetArchivedProjectsArgs, GetArchivedProjectsResponse, SearchCompletedTasksArgs, GetActivityLogsArgs, GetActivityLogsResponse, UploadFileArgs, DeleteUploadArgs, GetWorkspaceInvitationsArgs, DeleteWorkspaceInvitationArgs, WorkspaceInvitationActionArgs, JoinWorkspaceArgs, WorkspaceLogoArgs, GetWorkspacePlanDetailsArgs, GetWorkspaceUsersArgs, GetWorkspaceUsersResponse, GetWorkspaceProjectsArgs, WorkspaceInvitationsResponse, AllWorkspaceInvitationsResponse, WorkspaceLogoResponse, MoveProjectToWorkspaceArgs, MoveProjectToPersonalArgs } from './types/requests.js';
2
+ import { AddCommentArgs, AddLabelArgs, AddLocationReminderArgs, AddProjectArgs, AddReminderArgs, AddSectionArgs, AddTaskArgs, GetProjectCommentsArgs, GetTaskCommentsArgs, GetTasksArgs, GetTasksByFilterArgs, UpdateCommentArgs, UpdateLabelArgs, UpdateLocationReminderArgs, UpdateProjectArgs, UpdateReminderArgs, UpdateSectionArgs, UpdateTaskArgs, QuickAddTaskArgs, GetSharedLabelsArgs, RenameSharedLabelArgs, RemoveSharedLabelArgs, GetProjectsArgs, SearchProjectsArgs, GetProjectCollaboratorsArgs, GetLabelsArgs, SearchLabelsArgs, GetLabelsResponse, GetTasksResponse, GetProjectsResponse, GetProjectCollaboratorsResponse, GetSectionsArgs, SearchSectionsArgs, GetSectionsResponse, GetSharedLabelsResponse, GetCommentsResponse, type MoveTaskArgs, GetCompletedTasksByCompletionDateArgs, GetCompletedTasksByDueDateArgs, GetCompletedTasksResponse, GetArchivedProjectsArgs, GetArchivedProjectsResponse, SearchCompletedTasksArgs, GetActivityLogsArgs, GetActivityLogsResponse, UploadFileArgs, DeleteUploadArgs, GetWorkspaceInvitationsArgs, DeleteWorkspaceInvitationArgs, WorkspaceInvitationActionArgs, JoinWorkspaceArgs, WorkspaceLogoArgs, GetWorkspacePlanDetailsArgs, GetWorkspaceUsersArgs, GetWorkspaceUsersResponse, GetWorkspaceProjectsArgs, WorkspaceInvitationsResponse, AllWorkspaceInvitationsResponse, WorkspaceLogoResponse, MoveProjectToWorkspaceArgs, MoveProjectToPersonalArgs, GetArchivedProjectsCountArgs, GetArchivedProjectsCountResponse, GetProjectPermissionsResponse, GetFullProjectArgs, GetFullProjectResponse, AddWorkspaceArgs, UpdateWorkspaceArgs } from './types/requests.js';
3
3
  import { CustomFetch, CustomFetchResponse } from './types/http.js';
4
+ import type { Reminder } from './types/index.js';
4
5
  import { type SyncResponse, type SyncRequest } from './types/sync/index.js';
5
6
  /**
6
7
  * Response from viewAttachment, extending CustomFetchResponse with
@@ -270,6 +271,35 @@ export declare class TodoistApi {
270
271
  * @returns A promise that resolves to the moved project.
271
272
  */
272
273
  moveProjectToPersonal(args: MoveProjectToPersonalArgs, requestId?: string): Promise<PersonalProject | WorkspaceProject>;
274
+ /**
275
+ * Counts the number of archived projects.
276
+ *
277
+ * @param args - Optional parameters to filter the count.
278
+ * @returns A promise that resolves to the count of archived projects.
279
+ */
280
+ getArchivedProjectsCount(args?: GetArchivedProjectsCountArgs): Promise<GetArchivedProjectsCountResponse>;
281
+ /**
282
+ * Retrieves the role-to-action permission mappings for projects.
283
+ *
284
+ * @returns A promise that resolves to the permission mappings.
285
+ */
286
+ getProjectPermissions(): Promise<GetProjectPermissionsResponse>;
287
+ /**
288
+ * Retrieves full project data including tasks, sections, collaborators, and notes.
289
+ *
290
+ * @param id - The unique identifier of the project.
291
+ * @param args - Optional parameters.
292
+ * @returns A promise that resolves to the full project data.
293
+ */
294
+ getFullProject(id: string, args?: GetFullProjectArgs): Promise<GetFullProjectResponse>;
295
+ /**
296
+ * Joins a shared project by its ID.
297
+ *
298
+ * @param id - The unique identifier of the project to join.
299
+ * @param requestId - Optional custom identifier for the request.
300
+ * @returns A promise that resolves to the joined project.
301
+ */
302
+ joinProject(id: string, requestId?: string): Promise<PersonalProject | WorkspaceProject>;
273
303
  /**
274
304
  * Retrieves a list of collaborators for a specific project.
275
305
  *
@@ -325,6 +355,22 @@ export declare class TodoistApi {
325
355
  * @returns A promise that resolves to `true` if successful.
326
356
  */
327
357
  deleteSection(id: string, requestId?: string): Promise<boolean>;
358
+ /**
359
+ * Archives a section by its ID.
360
+ *
361
+ * @param id - The unique identifier of the section to archive.
362
+ * @param requestId - Optional custom identifier for the request.
363
+ * @returns A promise that resolves to the updated section.
364
+ */
365
+ archiveSection(id: string, requestId?: string): Promise<Section>;
366
+ /**
367
+ * Unarchives a section by its ID.
368
+ *
369
+ * @param id - The unique identifier of the section to unarchive.
370
+ * @param requestId - Optional custom identifier for the request.
371
+ * @returns A promise that resolves to the updated section.
372
+ */
373
+ unarchiveSection(id: string, requestId?: string): Promise<Section>;
328
374
  /**
329
375
  * Retrieves a label by its ID.
330
376
  *
@@ -431,6 +477,70 @@ export declare class TodoistApi {
431
477
  * @returns A promise that resolves to `true` if successful.
432
478
  */
433
479
  deleteComment(id: string, requestId?: string): Promise<boolean>;
480
+ /**
481
+ * Retrieves a time-based reminder by its ID.
482
+ *
483
+ * @param id - The unique identifier of the reminder to retrieve.
484
+ * @returns A promise that resolves to the requested reminder.
485
+ */
486
+ getReminder(id: string): Promise<Reminder>;
487
+ /**
488
+ * Retrieves a location reminder by its ID.
489
+ *
490
+ * @param id - The unique identifier of the location reminder to retrieve.
491
+ * @returns A promise that resolves to the requested reminder.
492
+ */
493
+ getLocationReminder(id: string): Promise<Reminder>;
494
+ /**
495
+ * Creates a time-based reminder for a task.
496
+ *
497
+ * @param args - Reminder creation parameters for relative or absolute reminders.
498
+ * @param requestId - Optional custom identifier for the request.
499
+ * @returns A promise that resolves to the created reminder.
500
+ */
501
+ addReminder(args: AddReminderArgs, requestId?: string): Promise<Reminder>;
502
+ /**
503
+ * Creates a location reminder for a task.
504
+ *
505
+ * @param args - Location reminder creation parameters.
506
+ * @param requestId - Optional custom identifier for the request.
507
+ * @returns A promise that resolves to the created reminder.
508
+ */
509
+ addLocationReminder(args: AddLocationReminderArgs, requestId?: string): Promise<Reminder>;
510
+ /**
511
+ * Updates an existing time-based reminder.
512
+ *
513
+ * @param id - The unique identifier of the reminder to update.
514
+ * @param args - Reminder update parameters.
515
+ * @param requestId - Optional custom identifier for the request.
516
+ * @returns A promise that resolves to the updated reminder.
517
+ */
518
+ updateReminder(id: string, args: UpdateReminderArgs, requestId?: string): Promise<Reminder>;
519
+ /**
520
+ * Updates an existing location reminder.
521
+ *
522
+ * @param id - The unique identifier of the location reminder to update.
523
+ * @param args - Location reminder update parameters.
524
+ * @param requestId - Optional custom identifier for the request.
525
+ * @returns A promise that resolves to the updated reminder.
526
+ */
527
+ updateLocationReminder(id: string, args: UpdateLocationReminderArgs, requestId?: string): Promise<Reminder>;
528
+ /**
529
+ * Deletes a time-based reminder by its ID.
530
+ *
531
+ * @param id - The unique identifier of the reminder to delete.
532
+ * @param requestId - Optional custom identifier for the request.
533
+ * @returns A promise that resolves to `true` if successful.
534
+ */
535
+ deleteReminder(id: string, requestId?: string): Promise<boolean>;
536
+ /**
537
+ * Deletes a location reminder by its ID.
538
+ *
539
+ * @param id - The unique identifier of the location reminder to delete.
540
+ * @param requestId - Optional custom identifier for the request.
541
+ * @returns A promise that resolves to `true` if successful.
542
+ */
543
+ deleteLocationReminder(id: string, requestId?: string): Promise<boolean>;
434
544
  /**
435
545
  * Retrieves productivity stats for the authenticated user.
436
546
  *
@@ -598,8 +708,6 @@ export declare class TodoistApi {
598
708
  /**
599
709
  * Retrieves all workspaces for the authenticated user.
600
710
  *
601
- * Uses the Sync API internally to fetch workspace data.
602
- *
603
711
  * @param requestId - Optional custom identifier for the request.
604
712
  * @returns A promise that resolves to an array of workspaces.
605
713
  *
@@ -612,6 +720,39 @@ export declare class TodoistApi {
612
720
  * ```
613
721
  */
614
722
  getWorkspaces(requestId?: string): Promise<Workspace[]>;
723
+ /**
724
+ * Retrieves a workspace by its ID.
725
+ *
726
+ * @param id - The unique identifier of the workspace.
727
+ * @param requestId - Optional custom identifier for the request.
728
+ * @returns A promise that resolves to the requested workspace.
729
+ */
730
+ getWorkspace(id: string, requestId?: string): Promise<Workspace>;
731
+ /**
732
+ * Creates a new workspace.
733
+ *
734
+ * @param args - The arguments for creating the workspace.
735
+ * @param requestId - Optional custom identifier for the request.
736
+ * @returns A promise that resolves to the created workspace.
737
+ */
738
+ addWorkspace(args: AddWorkspaceArgs, requestId?: string): Promise<Workspace>;
739
+ /**
740
+ * Updates an existing workspace.
741
+ *
742
+ * @param id - The unique identifier of the workspace to update.
743
+ * @param args - The arguments for updating the workspace.
744
+ * @param requestId - Optional custom identifier for the request.
745
+ * @returns A promise that resolves to the updated workspace.
746
+ */
747
+ updateWorkspace(id: string, args: UpdateWorkspaceArgs, requestId?: string): Promise<Workspace>;
748
+ /**
749
+ * Deletes a workspace by its ID.
750
+ *
751
+ * @param id - The unique identifier of the workspace to delete.
752
+ * @param requestId - Optional custom identifier for the request.
753
+ * @returns A promise that resolves to `true` if successful.
754
+ */
755
+ deleteWorkspace(id: string, requestId?: string): Promise<boolean>;
615
756
  /**
616
757
  * Gets active projects in a workspace with pagination.
617
758
  *
@@ -1,4 +1,4 @@
1
- import type { HttpResponse, RetryConfig, CustomFetch } from '../types/http.js';
1
+ import type { CustomFetch, HttpResponse, RetryConfig } from '../types/http.js';
2
2
  /**
3
3
  * Performs a fetch request with retry logic and timeout support
4
4
  */
@@ -1,4 +1,4 @@
1
- import { HttpMethod, HttpResponse, CustomFetch } from './types/http.js';
1
+ import type { CustomFetch, HttpMethod, HttpResponse } from '../types/http.js';
2
2
  type RequestArgs = {
3
3
  httpMethod: HttpMethod;
4
4
  baseUri: string;
@@ -0,0 +1,3 @@
1
+ import type { Dispatcher } from 'undici';
2
+ export declare function getDefaultDispatcher(): Promise<Dispatcher | undefined>;
3
+ export declare function resetDefaultDispatcherForTests(): Promise<void>;