@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
@@ -1,37 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  var __rest = (this && this.__rest) || function (s, e) {
36
3
  var t = {};
37
4
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -46,6 +13,7 @@ var __rest = (this && this.__rest) || function (s, e) {
46
13
  Object.defineProperty(exports, "__esModule", { value: true });
47
14
  exports.fetchWithRetry = fetchWithRetry;
48
15
  const http_1 = require("../types/http");
16
+ const http_dispatcher_1 = require("./http-dispatcher");
49
17
  /**
50
18
  * Default retry configuration matching the original axios-retry behavior
51
19
  */
@@ -58,32 +26,11 @@ const DEFAULT_RETRY_CONFIG = {
58
26
  return retryNumber === 1 ? 0 : 500;
59
27
  },
60
28
  };
61
- /**
62
- * Cached HTTP agent to prevent creating multiple agents
63
- * null = not initialized, undefined = browser env, UndiciAgent = Node.js env
64
- */
65
- let httpAgent = null;
66
- /**
67
- * Gets the HTTP agent for Node.js environments or undefined for browser environments.
68
- * Uses dynamic import to avoid loading undici in browser environments.
69
- */
70
- async function getHttpAgent() {
71
- var _a;
72
- if (httpAgent === null) {
73
- if (typeof process !== 'undefined' && ((_a = process.versions) === null || _a === void 0 ? void 0 : _a.node)) {
74
- // We're in Node.js - dynamically import undici
75
- const { Agent } = await Promise.resolve().then(() => __importStar(require('undici')));
76
- httpAgent = new Agent({
77
- keepAliveTimeout: 1, // Close connections after 1ms of idle time
78
- keepAliveMaxTimeout: 1, // Maximum time to keep connections alive
79
- });
80
- }
81
- else {
82
- // We're in browser - no agent needed
83
- httpAgent = undefined;
84
- }
85
- }
86
- return httpAgent;
29
+ const TIMEOUT_ERROR_NAME = 'TimeoutError';
30
+ function createTimeoutError(timeoutMs) {
31
+ const error = new Error(`Request timeout after ${timeoutMs}ms`);
32
+ error.name = TIMEOUT_ERROR_NAME;
33
+ return error;
87
34
  }
88
35
  /**
89
36
  * Converts Headers object to a plain object
@@ -103,10 +50,14 @@ function createTimeoutSignal(timeoutMs, existingSignal) {
103
50
  const controller = new AbortController();
104
51
  // Timeout logic
105
52
  const timeoutId = setTimeout(() => {
106
- controller.abort(new Error(`Request timeout after ${timeoutMs}ms`));
53
+ controller.abort(createTimeoutError(timeoutMs));
107
54
  }, timeoutMs);
55
+ let abortHandler;
108
56
  function clear() {
109
57
  clearTimeout(timeoutId);
58
+ if (existingSignal && abortHandler) {
59
+ existingSignal.removeEventListener('abort', abortHandler);
60
+ }
110
61
  }
111
62
  // If there's an existing signal, forward its abort
112
63
  if (existingSignal) {
@@ -115,10 +66,11 @@ function createTimeoutSignal(timeoutMs, existingSignal) {
115
66
  controller.abort(existingSignal.reason);
116
67
  }
117
68
  else {
118
- existingSignal.addEventListener('abort', () => {
69
+ abortHandler = () => {
119
70
  clearTimeout(timeoutId);
120
71
  controller.abort(existingSignal.reason);
121
- }, { once: true });
72
+ };
73
+ existingSignal.addEventListener('abort', abortHandler, { once: true });
122
74
  }
123
75
  }
124
76
  // Clean up timeout when request completes
@@ -167,9 +119,13 @@ async function fetchWithRetry(args) {
167
119
  fetchResponse = await customFetch(url, Object.assign(Object.assign({}, fetchOptions), { signal: requestSignal, timeout }));
168
120
  }
169
121
  else {
170
- const nativeResponse = await fetch(url, Object.assign(Object.assign({}, fetchOptions), { signal: requestSignal,
122
+ const dispatcher = await (0, http_dispatcher_1.getDefaultDispatcher)();
123
+ const nativeFetchOptions = Object.assign(Object.assign({}, fetchOptions), { signal: requestSignal });
124
+ if (dispatcher !== undefined) {
171
125
  // @ts-expect-error - dispatcher is a valid option for Node.js fetch but not in the TS types
172
- dispatcher: await getHttpAgent() }));
126
+ nativeFetchOptions.dispatcher = dispatcher;
127
+ }
128
+ const nativeResponse = await fetch(url, nativeFetchOptions);
173
129
  fetchResponse = convertResponseToCustomFetch(nativeResponse);
174
130
  }
175
131
  // Check if the response is successful
@@ -224,6 +180,9 @@ async function fetchWithRetry(args) {
224
180
  };
225
181
  }
226
182
  catch (error) {
183
+ if (clearTimeoutFn) {
184
+ clearTimeoutFn();
185
+ }
227
186
  lastError = error;
228
187
  // Check if this error should trigger a retry
229
188
  const shouldRetry = attempt < config.retries && config.retryCondition(lastError);
@@ -233,9 +192,6 @@ async function fetchWithRetry(args) {
233
192
  const networkError = lastError;
234
193
  networkError.isNetworkError = true;
235
194
  }
236
- if (clearTimeoutFn) {
237
- clearTimeoutFn();
238
- }
239
195
  throw lastError;
240
196
  }
241
197
  // Wait before retrying
@@ -243,10 +199,6 @@ async function fetchWithRetry(args) {
243
199
  if (delay > 0) {
244
200
  await new Promise((resolve) => setTimeout(resolve, delay));
245
201
  }
246
- // Retry path – ensure this attempt's timeout is cleared before looping
247
- if (clearTimeoutFn) {
248
- clearTimeoutFn();
249
- }
250
202
  }
251
203
  }
252
204
  // This should never be reached, but just in case
@@ -3,17 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.paramsSerializer = paramsSerializer;
4
4
  exports.isSuccess = isSuccess;
5
5
  exports.request = request;
6
- const errors_1 = require("./types/errors");
7
- const http_1 = require("./types/http");
8
6
  const uuid_1 = require("uuid");
9
- const endpoints_1 = require("./consts/endpoints");
10
- const case_conversion_1 = require("./utils/case-conversion");
11
- const fetch_with_retry_1 = require("./utils/fetch-with-retry");
7
+ const endpoints_1 = require("../consts/endpoints");
8
+ const errors_1 = require("../types/errors");
9
+ const http_1 = require("../types/http");
10
+ const case_conversion_1 = require("../utils/case-conversion");
11
+ const fetch_with_retry_1 = require("./fetch-with-retry");
12
12
  function paramsSerializer(params) {
13
13
  const qs = new URLSearchParams();
14
14
  Object.keys(params).forEach((key) => {
15
15
  const value = params[key];
16
- if (value != null) {
16
+ if (value !== null && value !== undefined) {
17
17
  if (Array.isArray(value)) {
18
18
  qs.append(key, JSON.stringify(value));
19
19
  }
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.getDefaultDispatcher = getDefaultDispatcher;
37
+ exports.resetDefaultDispatcherForTests = resetDefaultDispatcherForTests;
38
+ // Use effectively-disabled keep-alive so short-lived CLI processes do not stay
39
+ // open waiting on idle sockets. Undici requires positive values, so we use 1ms.
40
+ const KEEP_ALIVE_OPTIONS = {
41
+ keepAliveTimeout: 1,
42
+ keepAliveMaxTimeout: 1,
43
+ };
44
+ let defaultDispatcherPromise;
45
+ function getDefaultDispatcher() {
46
+ if (!isNodeEnvironment()) {
47
+ return Promise.resolve(undefined);
48
+ }
49
+ if (!defaultDispatcherPromise) {
50
+ defaultDispatcherPromise = createDefaultDispatcher().catch((error) => {
51
+ defaultDispatcherPromise = undefined;
52
+ throw error;
53
+ });
54
+ }
55
+ return defaultDispatcherPromise;
56
+ }
57
+ async function resetDefaultDispatcherForTests() {
58
+ if (!defaultDispatcherPromise) {
59
+ return;
60
+ }
61
+ const dispatcherPromise = defaultDispatcherPromise;
62
+ defaultDispatcherPromise = undefined;
63
+ await dispatcherPromise.then((dispatcher) => dispatcher.close(), () => undefined);
64
+ }
65
+ async function createDefaultDispatcher() {
66
+ const { EnvHttpProxyAgent } = await Promise.resolve().then(() => __importStar(require('undici')));
67
+ return new EnvHttpProxyAgent(KEEP_ALIVE_OPTIONS);
68
+ }
69
+ function isNodeEnvironment() {
70
+ var _a;
71
+ return typeof process !== 'undefined' && Boolean((_a = process.versions) === null || _a === void 0 ? void 0 : _a.node);
72
+ }
@@ -11,7 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  return t;
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.WorkspaceSchema = exports.WorkspacePropertiesSchema = exports.WorkspaceLimitsSchema = exports.WorkspacePlanSchema = exports.WORKSPACE_PLANS = exports.JoinWorkspaceResultSchema = exports.WorkspacePlanDetailsSchema = exports.WORKSPACE_PLAN_STATUSES = exports.WORKSPACE_CURRENT_PLANS = exports.FormattedPriceListingSchema = exports.PlanPriceSchema = exports.WorkspaceInvitationSchema = exports.WorkspaceUserSchema = exports.WorkspaceRoleSchema = exports.WORKSPACE_ROLES = exports.ActivityEventSchema = exports.ActivityEventExtraDataSchema = exports.ColorSchema = exports.ProductivityStatsSchema = exports.KarmaUpdateSchema = exports.ItemsWithDateSchema = exports.CompletedItemSchema = exports.StreakSchema = exports.CurrentUserSchema = exports.PREMIUM_STATUSES = exports.TimezoneInfoSchema = exports.UserSchema = exports.CommentSchema = exports.RawCommentSchema = exports.AttachmentSchema = exports.UPLOAD_STATES = exports.LabelSchema = exports.SectionSchema = exports.WorkspaceProjectSchema = exports.ProjectVisibilitySchema = exports.PROJECT_VISIBILITIES = exports.PersonalProjectSchema = exports.BaseProjectSchema = exports.TaskSchema = exports.DeadlineSchema = exports.DurationSchema = exports.DURATION_UNITS = exports.DueDateSchema = void 0;
14
+ exports.WorkspaceSchema = exports.WorkspacePropertiesSchema = exports.WorkspaceLimitsSchema = exports.WorkspacePlanSchema = exports.WORKSPACE_PLANS = exports.JoinWorkspaceResultSchema = exports.WorkspacePlanDetailsSchema = exports.WORKSPACE_PLAN_STATUSES = exports.WORKSPACE_CURRENT_PLANS = exports.FormattedPriceListingSchema = exports.PlanPriceSchema = exports.WorkspaceInvitationSchema = exports.WorkspaceUserSchema = exports.WorkspaceRoleSchema = exports.WORKSPACE_ROLES = exports.COLLABORATOR_ROLES = exports.ActivityEventSchema = exports.ActivityEventExtraDataSchema = exports.ColorSchema = exports.ProductivityStatsSchema = exports.KarmaUpdateSchema = exports.ItemsWithDateSchema = exports.CompletedItemSchema = exports.StreakSchema = exports.CurrentUserSchema = exports.PREMIUM_STATUSES = exports.TimezoneInfoSchema = exports.UserSchema = exports.CommentSchema = exports.RawCommentSchema = exports.AttachmentSchema = exports.UPLOAD_STATES = exports.LabelSchema = exports.SectionSchema = exports.PROJECT_VIEW_STYLES = exports.WorkspaceProjectSchema = exports.ProjectVisibilitySchema = exports.PROJECT_VISIBILITIES = exports.PersonalProjectSchema = exports.BaseProjectSchema = exports.TaskSchema = exports.DeadlineSchema = exports.DurationSchema = exports.DURATION_UNITS = exports.DueDateSchema = void 0;
15
15
  const zod_1 = require("zod");
16
16
  const url_helpers_1 = require("../utils/url-helpers");
17
17
  const uncompletable_helpers_1 = require("../utils/uncompletable-helpers");
@@ -117,6 +117,8 @@ exports.WorkspaceProjectSchema = exports.BaseProjectSchema.extend({
117
117
  }).transform((data) => {
118
118
  return Object.assign(Object.assign({}, data), { url: (0, url_helpers_1.getProjectUrl)(data.id, data.name) });
119
119
  });
120
+ /** Available project view styles. */
121
+ exports.PROJECT_VIEW_STYLES = ['list', 'board', 'calendar'];
120
122
  exports.SectionSchema = zod_1.z
121
123
  .object({
122
124
  id: zod_1.z.string(),
@@ -320,6 +322,14 @@ exports.ActivityEventSchema = zod_1.z
320
322
  extraData: exports.ActivityEventExtraDataSchema,
321
323
  })
322
324
  .catchall(zod_1.z.any());
325
+ /** Available project collaborator roles. */
326
+ exports.COLLABORATOR_ROLES = [
327
+ 'CREATOR',
328
+ 'ADMIN',
329
+ 'READ_WRITE',
330
+ 'EDIT_ONLY',
331
+ 'COMPLETE_ONLY',
332
+ ];
323
333
  /**
324
334
  * Available workspace roles.
325
335
  */
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TodoistRequestError = void 0;
3
+ exports.TodoistArgumentError = exports.TodoistRequestError = void 0;
4
4
  const ts_custom_error_1 = require("ts-custom-error");
5
5
  const authenticationErrorCodes = [401, 403];
6
6
  class TodoistRequestError extends ts_custom_error_1.CustomError {
7
- // eslint-disable-next-line max-params
8
7
  constructor(message, httpStatusCode, responseData) {
9
8
  super(message);
10
9
  this.message = message;
@@ -20,3 +19,11 @@ class TodoistRequestError extends ts_custom_error_1.CustomError {
20
19
  }
21
20
  }
22
21
  exports.TodoistRequestError = TodoistRequestError;
22
+ class TodoistArgumentError extends ts_custom_error_1.CustomError {
23
+ constructor(message) {
24
+ super(message);
25
+ this.message = message;
26
+ Object.defineProperty(this, 'name', { value: 'TodoistArgumentError' });
27
+ }
28
+ }
29
+ exports.TodoistArgumentError = TodoistArgumentError;
@@ -6,12 +6,14 @@ exports.isHttpError = isHttpError;
6
6
  * Type guard to check if an error is a network error
7
7
  */
8
8
  function isNetworkError(error) {
9
- // Network errors in fetch are typically TypeError with specific messages
9
+ // Network errors in fetch are typically TypeError with specific messages.
10
+ // Timeout errors are created by fetch-with-retry with the TimeoutError name.
10
11
  return ((error instanceof TypeError &&
11
12
  (error.message.includes('fetch') ||
12
13
  error.message.includes('network') ||
13
14
  error.message.includes('Failed to fetch') ||
14
15
  error.message.includes('NetworkError'))) ||
16
+ error.name === 'TimeoutError' ||
15
17
  error.isNetworkError === true);
16
18
  }
17
19
  /**
@@ -1,2 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.REMINDER_DELIVERY_SERVICES = void 0;
4
+ /** Available reminder delivery services. */
5
+ exports.REMINDER_DELIVERY_SERVICES = ['email', 'push'];
@@ -1,2 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LABEL_DELETE_CASCADE_MODES = void 0;
4
+ /** Available label delete cascade modes. */
5
+ exports.LABEL_DELETE_CASCADE_MODES = ['none', 'all'];
@@ -3,3 +3,18 @@
3
3
  * Shared types used across multiple Sync API command argument types.
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.WORKSPACE_PROJECT_SORT_ORDERS = exports.REMINDER_SERVICES = exports.COLLABORATOR_ROLES = exports.PROJECT_STATUSES = void 0;
7
+ /** Available project workflow statuses. */
8
+ exports.PROJECT_STATUSES = [
9
+ 'PLANNED',
10
+ 'IN_PROGRESS',
11
+ 'PAUSED',
12
+ 'COMPLETED',
13
+ 'CANCELED',
14
+ ];
15
+ var entities_1 = require("../../entities");
16
+ Object.defineProperty(exports, "COLLABORATOR_ROLES", { enumerable: true, get: function () { return entities_1.COLLABORATOR_ROLES; } });
17
+ /** Available reminder notification services. */
18
+ exports.REMINDER_SERVICES = ['default', 'email', 'mobile', 'push', 'no_default'];
19
+ /** Available workspace project sort orders. */
20
+ exports.WORKSPACE_PROJECT_SORT_ORDERS = ['MANUAL', 'A_TO_Z', 'Z_TO_A'];
@@ -23,11 +23,13 @@ exports.LocationReminderSchema = exports.ReminderBaseSchema.extend({
23
23
  exports.AbsoluteReminderSchema = exports.ReminderBaseSchema.extend({
24
24
  type: zod_1.z.literal('absolute'),
25
25
  due: entities_1.DueDateSchema,
26
+ isUrgent: zod_1.z.boolean().optional(),
26
27
  }).passthrough();
27
28
  exports.RelativeReminderSchema = exports.ReminderBaseSchema.extend({
28
29
  type: zod_1.z.literal('relative'),
29
30
  minuteOffset: zod_1.z.number().int(),
30
31
  due: entities_1.DueDateSchema.optional(),
32
+ isUrgent: zod_1.z.boolean().optional(),
31
33
  }).passthrough();
32
34
  exports.ReminderSchema = zod_1.z.discriminatedUnion('type', [
33
35
  exports.LocationReminderSchema,
@@ -1,10 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DayOfWeekSchema = exports.TimeFormatSchema = exports.DateFormatSchema = exports.BooleanFromZeroOneSchema = exports.DAY_OF_WEEK_TO_API = exports.TIME_FORMAT_TO_API = exports.DATE_FORMAT_TO_API = void 0;
3
+ exports.DayOfWeekSchema = exports.TimeFormatSchema = exports.DateFormatSchema = exports.BooleanFromZeroOneSchema = exports.DAY_OF_WEEK_TO_API = exports.TIME_FORMAT_TO_API = exports.DATE_FORMAT_TO_API = exports.DAY_OF_WEEK_FROM_API = exports.TIME_FORMAT_FROM_API = exports.DATE_FORMAT_FROM_API = exports.DAYS_OF_WEEK = exports.TIME_FORMATS = exports.DATE_FORMATS = void 0;
4
4
  const zod_1 = require("zod");
5
- const DATE_FORMAT_FROM_API = { 0: 'DD/MM/YYYY', 1: 'MM/DD/YYYY' };
6
- const TIME_FORMAT_FROM_API = { 0: '24h', 1: '12h' };
7
- const DAY_OF_WEEK_FROM_API = {
5
+ /** Available date format options. */
6
+ exports.DATE_FORMATS = ['DD/MM/YYYY', 'MM/DD/YYYY'];
7
+ /** Available time format options. */
8
+ exports.TIME_FORMATS = ['24h', '12h'];
9
+ /** Available days of the week. */
10
+ exports.DAYS_OF_WEEK = [
11
+ 'Monday',
12
+ 'Tuesday',
13
+ 'Wednesday',
14
+ 'Thursday',
15
+ 'Friday',
16
+ 'Saturday',
17
+ 'Sunday',
18
+ ];
19
+ exports.DATE_FORMAT_FROM_API = {
20
+ 0: 'DD/MM/YYYY',
21
+ 1: 'MM/DD/YYYY',
22
+ };
23
+ exports.TIME_FORMAT_FROM_API = {
24
+ 0: '24h',
25
+ 1: '12h',
26
+ };
27
+ exports.DAY_OF_WEEK_FROM_API = {
8
28
  1: 'Monday',
9
29
  2: 'Tuesday',
10
30
  3: 'Wednesday',
@@ -34,10 +54,10 @@ exports.BooleanFromZeroOneSchema = zod_1.z
34
54
  /** Zod read-schemas: parse API numbers, emit descriptive strings */
35
55
  exports.DateFormatSchema = zod_1.z
36
56
  .union([zod_1.z.literal(0), zod_1.z.literal(1)])
37
- .transform((v) => DATE_FORMAT_FROM_API[v]);
57
+ .transform((v) => exports.DATE_FORMAT_FROM_API[v]);
38
58
  exports.TimeFormatSchema = zod_1.z
39
59
  .union([zod_1.z.literal(0), zod_1.z.literal(1)])
40
- .transform((v) => TIME_FORMAT_FROM_API[v]);
60
+ .transform((v) => exports.TIME_FORMAT_FROM_API[v]);
41
61
  exports.DayOfWeekSchema = zod_1.z
42
62
  .union([
43
63
  zod_1.z.literal(1),
@@ -48,4 +68,4 @@ exports.DayOfWeekSchema = zod_1.z
48
68
  zod_1.z.literal(6),
49
69
  zod_1.z.literal(7),
50
70
  ])
51
- .transform((v) => DAY_OF_WEEK_FROM_API[v]);
71
+ .transform((v) => exports.DAY_OF_WEEK_FROM_API[v]);
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.uploadMultipartFile = uploadMultipartFile;
37
- const fetch_with_retry_1 = require("./fetch-with-retry");
37
+ const fetch_with_retry_1 = require("../transport/fetch-with-retry");
38
38
  /**
39
39
  * Helper function to determine content-type from filename extension.
40
40
  * @param fileName - The filename to analyze
@@ -18,7 +18,7 @@ function removeStyleFormatting(input) {
18
18
  if (!input.includes('!') && !input.includes('*') && !input.includes('_')) {
19
19
  return input;
20
20
  }
21
- function removeMarkdown(match, prefix, text) {
21
+ function removeMarkdown(_match, prefix, text) {
22
22
  return `${prefix}${text}`;
23
23
  }
24
24
  input = input.replace(BOLD_ITALIC_FORMAT, removeMarkdown);
@@ -27,7 +27,7 @@ function removeStyleFormatting(input) {
27
27
  return input;
28
28
  }
29
29
  function removeCodeFormatting(input) {
30
- function removeMarkdown(match, text) {
30
+ function removeMarkdown(_match, text) {
31
31
  return text;
32
32
  }
33
33
  input = input.replace(CODE_BLOCK_FORMAT, removeMarkdown);
@@ -47,7 +47,7 @@ function removeMarkdownLinks(input) {
47
47
  if (!input.includes('[') || !input.includes(']')) {
48
48
  return input;
49
49
  }
50
- function removeMarkdown(match, text) {
50
+ function removeMarkdown(_match, text) {
51
51
  return text;
52
52
  }
53
53
  return input.replace(MARKDOWN_LINK, removeMarkdown);
@@ -56,20 +56,20 @@ function removeTodoistLinks(input) {
56
56
  if (!input.includes('(') || !input.includes(')')) {
57
57
  return input;
58
58
  }
59
- function removeMarkdown(match, url, text) {
59
+ function removeMarkdown(_match, _url, text) {
60
60
  return text;
61
61
  }
62
62
  return input.replace(TODOIST_LINK, removeMarkdown);
63
63
  }
64
64
  function removeAppLinks(input) {
65
65
  if (input.includes('gmail')) {
66
- input = input.replace(GMAIL_LINK, (match, id, text) => text);
66
+ input = input.replace(GMAIL_LINK, (_match, _id, text) => text);
67
67
  }
68
68
  if (input.includes('outlook')) {
69
- input = input.replace(OUTLOOK_LINK, (match, id, text) => text);
69
+ input = input.replace(OUTLOOK_LINK, (_match, _id, text) => text);
70
70
  }
71
71
  if (input.includes('thunderbird')) {
72
- input = input.replace(THUNDERBIRD_LINK, (match, text) => text);
72
+ input = input.replace(THUNDERBIRD_LINK, (_match, text) => text);
73
73
  }
74
74
  return input;
75
75
  }
@@ -1,7 +1,16 @@
1
- import { request, isSuccess } from './rest-client.js';
1
+ import { request, isSuccess } from './transport/http-client.js';
2
2
  import { v4 as uuid } from 'uuid';
3
3
  import { TodoistRequestError } from './types/index.js';
4
4
  import { getAuthBaseUri, getSyncBaseUri, ENDPOINT_AUTHORIZATION, ENDPOINT_GET_TOKEN, ENDPOINT_REVOKE, } from './consts/endpoints.js';
5
+ /** Available OAuth2 permission scopes. */
6
+ export const PERMISSIONS = [
7
+ 'task:add',
8
+ 'data:read',
9
+ 'data:read_write',
10
+ 'data:delete',
11
+ 'project:delete',
12
+ 'backups:read',
13
+ ];
5
14
  /**
6
15
  * Creates a Basic Authentication header value from client credentials.
7
16
  * @param clientId - The OAuth client ID
@@ -25,6 +25,8 @@ export const ENDPOINT_REST_LABELS_SHARED = ENDPOINT_REST_LABELS + '/shared';
25
25
  export const ENDPOINT_REST_LABELS_SHARED_RENAME = ENDPOINT_REST_LABELS_SHARED + '/rename';
26
26
  export const ENDPOINT_REST_LABELS_SHARED_REMOVE = ENDPOINT_REST_LABELS_SHARED + '/remove';
27
27
  export const ENDPOINT_REST_COMMENTS = 'comments';
28
+ export const ENDPOINT_REST_REMINDERS = 'reminders';
29
+ export const ENDPOINT_REST_LOCATION_REMINDERS = 'location_reminders';
28
30
  export const ENDPOINT_REST_TASK_CLOSE = 'close';
29
31
  export const ENDPOINT_REST_TASK_REOPEN = 'reopen';
30
32
  export const ENDPOINT_REST_TASK_MOVE = 'move';
@@ -38,6 +40,12 @@ export const ENDPOINT_REST_ACTIVITIES = 'activities';
38
40
  export const ENDPOINT_REST_UPLOADS = 'uploads';
39
41
  export const PROJECT_ARCHIVE = 'archive';
40
42
  export const PROJECT_UNARCHIVE = 'unarchive';
43
+ export const ENDPOINT_REST_PROJECTS_ARCHIVED_COUNT = ENDPOINT_REST_PROJECTS + '/archived/count';
44
+ export const ENDPOINT_REST_PROJECTS_PERMISSIONS = ENDPOINT_REST_PROJECTS + '/permissions';
45
+ export const ENDPOINT_REST_PROJECT_FULL = 'full';
46
+ export const ENDPOINT_REST_PROJECT_JOIN = 'join';
47
+ export const SECTION_ARCHIVE = 'archive';
48
+ export const SECTION_UNARCHIVE = 'unarchive';
41
49
  export const ENDPOINT_REST_PROJECTS_MOVE_TO_WORKSPACE = ENDPOINT_REST_PROJECTS + '/move_to_workspace';
42
50
  export const ENDPOINT_REST_PROJECTS_MOVE_TO_PERSONAL = ENDPOINT_REST_PROJECTS + '/move_to_personal';
43
51
  export const ENDPOINT_SYNC_QUICK_ADD = ENDPOINT_REST_TASKS + '/quick';
@@ -46,6 +54,7 @@ export const ENDPOINT_AUTHORIZATION = 'authorize';
46
54
  export const ENDPOINT_GET_TOKEN = 'access_token';
47
55
  export const ENDPOINT_REVOKE = 'revoke';
48
56
  // Workspace endpoints
57
+ export const ENDPOINT_REST_WORKSPACES = 'workspaces';
49
58
  export const ENDPOINT_WORKSPACE_INVITATIONS = 'workspaces/invitations';
50
59
  export const ENDPOINT_WORKSPACE_INVITATIONS_ALL = 'workspaces/invitations/all';
51
60
  export const ENDPOINT_WORKSPACE_INVITATIONS_DELETE = 'workspaces/invitations/delete';
@@ -1,5 +1,5 @@
1
1
  // Has to use 'any' to express constructor type
2
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2
+ // oxlint-disable-next-line no-explicit-any
3
3
  export function assertInstance(value, type) {
4
4
  if (value instanceof type) {
5
5
  return;
@@ -176,6 +176,38 @@ export const DEFAULT_RAW_COMMENT = {
176
176
  itemId: DEFAULT_TASK_ID,
177
177
  };
178
178
  export const DEFAULT_COMMENT = Object.assign(Object.assign({}, DEFAULT_RAW_COMMENT), { taskId: DEFAULT_RAW_COMMENT.itemId, itemId: undefined });
179
+ export const DEFAULT_REMINDER_ID = '6XGgmFQrx44wfGHr';
180
+ export const DEFAULT_RELATIVE_REMINDER = {
181
+ id: DEFAULT_REMINDER_ID,
182
+ itemId: DEFAULT_TASK_ID,
183
+ notifyUid: DEFAULT_USER_ID,
184
+ isDeleted: false,
185
+ type: 'relative',
186
+ minuteOffset: 30,
187
+ due: DEFAULT_DUE_DATE,
188
+ isUrgent: false,
189
+ };
190
+ export const DEFAULT_ABSOLUTE_REMINDER = {
191
+ id: DEFAULT_REMINDER_ID,
192
+ itemId: DEFAULT_TASK_ID,
193
+ notifyUid: DEFAULT_USER_ID,
194
+ isDeleted: false,
195
+ type: 'absolute',
196
+ due: DEFAULT_DUE_DATE,
197
+ isUrgent: true,
198
+ };
199
+ export const DEFAULT_LOCATION_REMINDER = {
200
+ id: DEFAULT_REMINDER_ID,
201
+ itemId: DEFAULT_TASK_ID,
202
+ notifyUid: DEFAULT_USER_ID,
203
+ isDeleted: false,
204
+ type: 'location',
205
+ name: 'Aliados',
206
+ locLat: '41.148581',
207
+ locLong: '-8.610945000000015',
208
+ locTrigger: 'on_enter',
209
+ radius: 100,
210
+ };
179
211
  export const INVALID_COMMENT = Object.assign(Object.assign({}, DEFAULT_RAW_COMMENT), { isDeleted: 'true' });
180
212
  export const RAW_COMMENT_WITH_OPTIONALS_AS_NULL_TASK = Object.assign(Object.assign({}, DEFAULT_RAW_COMMENT), { fileAttachment: null, uidsToNotify: null, reactions: null });
181
213
  export const COMMENT_WITH_OPTIONALS_AS_NULL_TASK = Object.assign(Object.assign({}, RAW_COMMENT_WITH_OPTIONALS_AS_NULL_TASK), { taskId: RAW_COMMENT_WITH_OPTIONALS_AS_NULL_TASK.itemId, itemId: undefined });