@doist/todoist-sdk 10.5.0 → 11.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.
Files changed (60) hide show
  1. package/dist/cjs/consts/endpoints.js +1 -6
  2. package/dist/cjs/test-utils/test-defaults.js +2 -26
  3. package/dist/cjs/test-utils/transport-seam.js +17 -0
  4. package/dist/cjs/test-utils/webhook-fixtures.js +1 -1
  5. package/dist/cjs/todoist-api.js +0 -101
  6. package/dist/cjs/transport/fetch-with-retry.js +19 -7
  7. package/dist/cjs/transport/http-dispatcher.js +60 -15
  8. package/dist/cjs/types/index.js +0 -1
  9. package/dist/cjs/types/sync/commands/index.js +0 -2
  10. package/dist/cjs/types/sync/resource-types.js +0 -2
  11. package/dist/cjs/types/sync/resources/index.js +0 -1
  12. package/dist/cjs/types/sync/response.js +10 -13
  13. package/dist/cjs/utils/validators.js +50 -54
  14. package/dist/esm/consts/endpoints.js +0 -5
  15. package/dist/esm/test-utils/test-defaults.js +0 -24
  16. package/dist/esm/test-utils/transport-seam.js +15 -0
  17. package/dist/esm/test-utils/webhook-fixtures.js +1 -1
  18. package/dist/esm/todoist-api.js +0 -101
  19. package/dist/esm/transport/fetch-with-retry.js +20 -8
  20. package/dist/esm/transport/http-dispatcher.js +58 -15
  21. package/dist/esm/types/index.js +0 -1
  22. package/dist/esm/types/sync/commands/index.js +0 -2
  23. package/dist/esm/types/sync/resource-types.js +0 -2
  24. package/dist/esm/types/sync/resources/index.js +0 -1
  25. package/dist/esm/types/sync/response.js +1 -4
  26. package/dist/esm/utils/validators.js +1 -4
  27. package/dist/types/consts/endpoints.d.ts +0 -5
  28. package/dist/types/test-utils/test-defaults.d.ts +1 -4
  29. package/dist/types/todoist-api.d.ts +0 -80
  30. package/dist/types/transport/http-dispatcher.d.ts +36 -0
  31. package/dist/types/types/index.d.ts +0 -1
  32. package/dist/types/types/sync/commands/index.d.ts +0 -16
  33. package/dist/types/types/sync/resource-types.d.ts +1 -1
  34. package/dist/types/types/sync/resources/index.d.ts +0 -1
  35. package/dist/types/types/sync/resources/view-options.d.ts +6 -6
  36. package/dist/types/types/sync/response.d.ts +4 -45
  37. package/dist/types/types/tasks/requests.d.ts +0 -1
  38. package/dist/types/utils/validators.d.ts +8 -90
  39. package/package.json +1 -1
  40. package/dist/cjs/clients/goals-client.js +0 -144
  41. package/dist/cjs/types/goals/index.js +0 -18
  42. package/dist/cjs/types/goals/requests.js +0 -2
  43. package/dist/cjs/types/goals/types.js +0 -56
  44. package/dist/cjs/types/sync/commands/goals.js +0 -2
  45. package/dist/cjs/types/sync/commands/workspace-goals.js +0 -2
  46. package/dist/cjs/types/sync/resources/workspace-goals.js +0 -26
  47. package/dist/esm/clients/goals-client.js +0 -140
  48. package/dist/esm/types/goals/index.js +0 -2
  49. package/dist/esm/types/goals/types.js +0 -53
  50. package/dist/esm/types/sync/commands/goals.js +0 -1
  51. package/dist/esm/types/sync/commands/workspace-goals.js +0 -1
  52. package/dist/esm/types/sync/resources/workspace-goals.js +0 -23
  53. package/dist/types/clients/goals-client.d.ts +0 -20
  54. package/dist/types/types/goals/index.d.ts +0 -2
  55. package/dist/types/types/goals/requests.d.ts +0 -33
  56. package/dist/types/types/goals/types.d.ts +0 -51
  57. package/dist/types/types/sync/commands/goals.d.ts +0 -33
  58. package/dist/types/types/sync/commands/workspace-goals.d.ts +0 -24
  59. package/dist/types/types/sync/resources/workspace-goals.d.ts +0 -29
  60. /package/dist/{esm/types/goals/requests.js → types/test-utils/transport-seam.d.ts} +0 -0
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ENDPOINT_REST_ID_MAPPINGS = exports.ENDPOINT_REST_EMAILS = exports.ENDPOINT_REST_BACKUPS_DOWNLOAD = exports.ENDPOINT_REST_BACKUPS = exports.ENDPOINT_REST_ACCESS_TOKENS_MIGRATE = exports.ENDPOINT_REST_TEMPLATES_IMPORT_FROM_ID = exports.ENDPOINT_REST_TEMPLATES_IMPORT_FROM_FILE = exports.ENDPOINT_REST_TEMPLATES_CREATE_FROM_FILE = exports.ENDPOINT_REST_TEMPLATES_URL = exports.ENDPOINT_REST_TEMPLATES_FILE = exports.ENDPOINT_REST_TASKS_COMPLETED = exports.ENDPOINT_REST_PROJECTS_MOVE_TO_PERSONAL = exports.ENDPOINT_REST_PROJECTS_MOVE_TO_WORKSPACE = exports.SECTION_UNARCHIVE = exports.SECTION_ARCHIVE = exports.ENDPOINT_REST_PROJECT_JOIN = exports.ENDPOINT_REST_PROJECT_FULL = exports.ENDPOINT_REST_PROJECTS_PERMISSIONS = exports.ENDPOINT_REST_PROJECTS_ARCHIVED_COUNT = exports.PROJECT_UNARCHIVE = exports.PROJECT_ARCHIVE = exports.ENDPOINT_REST_UPLOADS = exports.ENDPOINT_REST_ACTIVITIES = exports.ENDPOINT_REST_PRODUCTIVITY = exports.ENDPOINT_REST_USER = exports.ENDPOINT_REST_PROJECT_COLLABORATORS = exports.ENDPOINT_REST_PROJECTS_ARCHIVED = exports.ENDPOINT_REST_PROJECTS_SEARCH = exports.ENDPOINT_REST_PROJECTS = exports.ENDPOINT_REST_TASK_MOVE = exports.ENDPOINT_REST_TASK_REOPEN = exports.ENDPOINT_REST_TASK_CLOSE = exports.ENDPOINT_REST_LOCATION_REMINDERS = exports.ENDPOINT_REST_REMINDERS = exports.ENDPOINT_REST_COMMENTS = exports.ENDPOINT_REST_LABELS_SHARED_REMOVE = exports.ENDPOINT_REST_LABELS_SHARED_RENAME = exports.ENDPOINT_REST_LABELS_SHARED = exports.ENDPOINT_REST_LABELS_SEARCH = exports.ENDPOINT_REST_LABELS = exports.ENDPOINT_REST_SECTIONS_SEARCH = exports.ENDPOINT_REST_SECTIONS = exports.ENDPOINT_REST_TASKS_COMPLETED_SEARCH = exports.ENDPOINT_REST_TASKS_COMPLETED_BY_DUE_DATE = exports.ENDPOINT_REST_TASKS_COMPLETED_BY_COMPLETION_DATE = exports.ENDPOINT_REST_TASKS_FILTER = exports.ENDPOINT_REST_TASKS = exports.API_BASE_URI = exports.API_VERSION = exports.TODOIST_WEB_URI = void 0;
4
- exports.APP_ICON_SIZES = exports.ENDPOINT_REST_USER_AUTHORIZATIONS_DELETE = exports.ENDPOINT_REST_USER_AUTHORIZATIONS = exports.ENDPOINT_REST_APPS_UI_EXTENSIONS_INSTALLED = exports.ENDPOINT_REST_APPS_UI_EXTENSIONS = exports.ENDPOINT_REST_APPS_INSTALLATIONS = exports.ENDPOINT_REST_APPS = exports.ENDPOINT_WORKSPACE_MEMBERS = exports.ENDPOINT_PRICING = exports.ENDPOINT_PRICES = exports.ENDPOINT_WORKSPACE_BILLING_PORTAL = exports.ENDPOINT_WORKSPACE_TRIAL = exports.ENDPOINT_WORKSPACE_UPGRADE = exports.ENDPOINT_PRO_PLAN_DETAILS = exports.ENDPOINT_PRO_BILLING_PORTAL = exports.ENDPOINT_PRO_TRIAL = exports.ENDPOINT_PRO_UPGRADE = exports.ENDPOINT_PAYMENTS_REACTIVATE_PLAN = exports.ENDPOINT_PAYMENTS_CANCEL_PLAN = exports.ENDPOINT_PAYMENTS_SUBSCRIPTION_INFO = exports.ENDPOINT_WORKSPACE_USERS = exports.ENDPOINT_WORKSPACE_PLAN_DETAILS = exports.ENDPOINT_WORKSPACE_LOGO = exports.ENDPOINT_WORKSPACE_JOIN = exports.ENDPOINT_WORKSPACE_INVITATIONS_DELETE = exports.ENDPOINT_WORKSPACE_INVITATIONS_ALL = exports.ENDPOINT_WORKSPACE_INVITATIONS = exports.ENDPOINT_REST_WORKSPACES = exports.GOAL_TASKS = exports.GOAL_UNCOMPLETE = exports.GOAL_COMPLETE = exports.ENDPOINT_REST_GOALS_SEARCH = exports.ENDPOINT_REST_GOALS = exports.ENDPOINT_REST_FOLDERS = exports.ENDPOINT_REGISTER = exports.ENDPOINT_REVOKE = exports.ENDPOINT_GET_TOKEN = exports.ENDPOINT_AUTHORIZATION = exports.ENDPOINT_SYNC = exports.ENDPOINT_SYNC_QUICK_ADD = exports.ENDPOINT_REST_MOVED_IDS = void 0;
4
+ exports.APP_ICON_SIZES = exports.ENDPOINT_REST_USER_AUTHORIZATIONS_DELETE = exports.ENDPOINT_REST_USER_AUTHORIZATIONS = exports.ENDPOINT_REST_APPS_UI_EXTENSIONS_INSTALLED = exports.ENDPOINT_REST_APPS_UI_EXTENSIONS = exports.ENDPOINT_REST_APPS_INSTALLATIONS = exports.ENDPOINT_REST_APPS = exports.ENDPOINT_WORKSPACE_MEMBERS = exports.ENDPOINT_PRICING = exports.ENDPOINT_PRICES = exports.ENDPOINT_WORKSPACE_BILLING_PORTAL = exports.ENDPOINT_WORKSPACE_TRIAL = exports.ENDPOINT_WORKSPACE_UPGRADE = exports.ENDPOINT_PRO_PLAN_DETAILS = exports.ENDPOINT_PRO_BILLING_PORTAL = exports.ENDPOINT_PRO_TRIAL = exports.ENDPOINT_PRO_UPGRADE = exports.ENDPOINT_PAYMENTS_REACTIVATE_PLAN = exports.ENDPOINT_PAYMENTS_CANCEL_PLAN = exports.ENDPOINT_PAYMENTS_SUBSCRIPTION_INFO = exports.ENDPOINT_WORKSPACE_USERS = exports.ENDPOINT_WORKSPACE_PLAN_DETAILS = exports.ENDPOINT_WORKSPACE_LOGO = exports.ENDPOINT_WORKSPACE_JOIN = exports.ENDPOINT_WORKSPACE_INVITATIONS_DELETE = exports.ENDPOINT_WORKSPACE_INVITATIONS_ALL = exports.ENDPOINT_WORKSPACE_INVITATIONS = exports.ENDPOINT_REST_WORKSPACES = exports.ENDPOINT_REST_FOLDERS = exports.ENDPOINT_REGISTER = exports.ENDPOINT_REVOKE = exports.ENDPOINT_GET_TOKEN = exports.ENDPOINT_AUTHORIZATION = exports.ENDPOINT_SYNC = exports.ENDPOINT_SYNC_QUICK_ADD = exports.ENDPOINT_REST_MOVED_IDS = void 0;
5
5
  exports.getSyncBaseUri = getSyncBaseUri;
6
6
  exports.getApiRootBaseUri = getApiRootBaseUri;
7
7
  exports.getAuthBaseUri = getAuthBaseUri;
@@ -104,11 +104,6 @@ exports.ENDPOINT_GET_TOKEN = 'access_token';
104
104
  exports.ENDPOINT_REVOKE = 'revoke';
105
105
  exports.ENDPOINT_REGISTER = 'register';
106
106
  exports.ENDPOINT_REST_FOLDERS = 'folders';
107
- exports.ENDPOINT_REST_GOALS = 'goals';
108
- exports.ENDPOINT_REST_GOALS_SEARCH = exports.ENDPOINT_REST_GOALS + '/search';
109
- exports.GOAL_COMPLETE = 'complete';
110
- exports.GOAL_UNCOMPLETE = 'uncomplete';
111
- exports.GOAL_TASKS = 'items';
112
107
  // Workspace endpoints
113
108
  exports.ENDPOINT_REST_WORKSPACES = 'workspaces';
114
109
  exports.ENDPOINT_WORKSPACE_INVITATIONS = 'workspaces/invitations';
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_INSTALLATION_ID = exports.DEFAULT_APP_ID = exports.DEFAULT_GOAL_NO_PROGRESS = exports.DEFAULT_GOAL = exports.DEFAULT_GOAL_ID = exports.DEFAULT_COLLABORATOR_STATE = exports.DEFAULT_COLLABORATOR = exports.DEFAULT_FOLDER = exports.COMMENT_WITH_OPTIONALS_AS_NULL_PROJECT = exports.RAW_COMMENT_WITH_OPTIONALS_AS_NULL_PROJECT = exports.COMMENT_WITH_ATTACHMENT_WITH_OPTIONALS_AS_NULL = exports.RAW_COMMENT_WITH_ATTACHMENT_WITH_OPTIONALS_AS_NULL = exports.COMMENT_WITH_OPTIONALS_AS_NULL_TASK = exports.RAW_COMMENT_WITH_OPTIONALS_AS_NULL_TASK = exports.INVALID_COMMENT = exports.DEFAULT_LOCATION_REMINDER = exports.DEFAULT_ABSOLUTE_REMINDER = exports.DEFAULT_RELATIVE_REMINDER = exports.DEFAULT_REMINDER_ID = exports.DEFAULT_COMMENT = exports.DEFAULT_RAW_COMMENT = exports.INVALID_ATTACHMENT = exports.DEFAULT_ATTACHMENT = exports.INVALID_USER = exports.DEFAULT_USER = exports.INVALID_LABEL = exports.DEFAULT_LABEL = exports.INVALID_SECTION = exports.DEFAULT_SECTION = exports.DEFAULT_WORKSPACE_PROJECT = exports.PROJECT_WITH_OPTIONALS_AS_NULL = exports.INVALID_PROJECT = exports.DEFAULT_PROJECT = exports.TASK_WITH_OPTIONALS_AS_NULL = exports.INVALID_TASK = exports.DEFAULT_TASK = exports.DEFAULT_DEADLINE = exports.DEFAULT_DURATION = exports.DEFAULT_DUE_DATE = exports.INVALID_ENTITY_ID = exports.DEFAULT_REQUEST_ID = exports.DEFAULT_AUTH_TOKEN = exports.DEFAULT_PROJECT_VIEW_STYLE = exports.DEFAULT_PROJECT_NAME = exports.DEFAULT_PROJECT_ID = exports.DEFAULT_ORDER = exports.DEFAULT_TASK_PRIORITY = exports.DEFAULT_TASK_DESCRIPTION = exports.DEFAULT_TASK_CONTENT = exports.DEFAULT_TASK_ID = void 0;
4
- exports.DEFAULT_NOTE = exports.DEFAULT_UI_EXTENSION = exports.DEFAULT_USER_AUTHORIZATION = exports.DEFAULT_APP_INSTALLATION = exports.DEFAULT_APP_WEBHOOK = exports.DEFAULT_APP_DISTRIBUTION_TOKEN = exports.DEFAULT_APP_TEST_TOKEN = exports.DEFAULT_APP_VERIFICATION_TOKEN = exports.DEFAULT_APP_SECRETS = exports.DEFAULT_APP_WITH_USER_COUNT = exports.DEFAULT_APP = exports.DEFAULT_ACCESS_TOKEN_ID = exports.DEFAULT_DISTRIBUTION_TOKEN = exports.DEFAULT_UI_EXTENSION_ID = void 0;
3
+ exports.DEFAULT_ACCESS_TOKEN_ID = exports.DEFAULT_DISTRIBUTION_TOKEN = exports.DEFAULT_UI_EXTENSION_ID = exports.DEFAULT_INSTALLATION_ID = exports.DEFAULT_APP_ID = exports.DEFAULT_COLLABORATOR_STATE = exports.DEFAULT_COLLABORATOR = exports.DEFAULT_FOLDER = exports.COMMENT_WITH_OPTIONALS_AS_NULL_PROJECT = exports.RAW_COMMENT_WITH_OPTIONALS_AS_NULL_PROJECT = exports.COMMENT_WITH_ATTACHMENT_WITH_OPTIONALS_AS_NULL = exports.RAW_COMMENT_WITH_ATTACHMENT_WITH_OPTIONALS_AS_NULL = exports.COMMENT_WITH_OPTIONALS_AS_NULL_TASK = exports.RAW_COMMENT_WITH_OPTIONALS_AS_NULL_TASK = exports.INVALID_COMMENT = exports.DEFAULT_LOCATION_REMINDER = exports.DEFAULT_ABSOLUTE_REMINDER = exports.DEFAULT_RELATIVE_REMINDER = exports.DEFAULT_REMINDER_ID = exports.DEFAULT_COMMENT = exports.DEFAULT_RAW_COMMENT = exports.INVALID_ATTACHMENT = exports.DEFAULT_ATTACHMENT = exports.INVALID_USER = exports.DEFAULT_USER = exports.INVALID_LABEL = exports.DEFAULT_LABEL = exports.INVALID_SECTION = exports.DEFAULT_SECTION = exports.DEFAULT_WORKSPACE_PROJECT = exports.PROJECT_WITH_OPTIONALS_AS_NULL = exports.INVALID_PROJECT = exports.DEFAULT_PROJECT = exports.TASK_WITH_OPTIONALS_AS_NULL = exports.INVALID_TASK = exports.DEFAULT_TASK = exports.DEFAULT_DEADLINE = exports.DEFAULT_DURATION = exports.DEFAULT_DUE_DATE = exports.INVALID_ENTITY_ID = exports.DEFAULT_REQUEST_ID = exports.DEFAULT_AUTH_TOKEN = exports.DEFAULT_PROJECT_VIEW_STYLE = exports.DEFAULT_PROJECT_NAME = exports.DEFAULT_PROJECT_ID = exports.DEFAULT_ORDER = exports.DEFAULT_TASK_PRIORITY = exports.DEFAULT_TASK_DESCRIPTION = exports.DEFAULT_TASK_CONTENT = exports.DEFAULT_TASK_ID = void 0;
4
+ exports.DEFAULT_NOTE = exports.DEFAULT_UI_EXTENSION = exports.DEFAULT_USER_AUTHORIZATION = exports.DEFAULT_APP_INSTALLATION = exports.DEFAULT_APP_WEBHOOK = exports.DEFAULT_APP_DISTRIBUTION_TOKEN = exports.DEFAULT_APP_TEST_TOKEN = exports.DEFAULT_APP_VERIFICATION_TOKEN = exports.DEFAULT_APP_SECRETS = exports.DEFAULT_APP_WITH_USER_COUNT = exports.DEFAULT_APP = void 0;
5
5
  const url_helpers_1 = require("../utils/url-helpers");
6
6
  exports.DEFAULT_TASK_ID = '1234';
7
7
  exports.DEFAULT_TASK_CONTENT = 'This is a task';
@@ -282,30 +282,6 @@ exports.DEFAULT_COLLABORATOR_STATE = {
282
282
  state: 'active',
283
283
  isDeleted: false,
284
284
  };
285
- exports.DEFAULT_GOAL_ID = '550e8400-e29b-41d4-a716-446655440000';
286
- exports.DEFAULT_GOAL = {
287
- id: exports.DEFAULT_GOAL_ID,
288
- ownerType: 'USER',
289
- ownerId: DEFAULT_USER_ID,
290
- name: 'Ship v2',
291
- description: 'Launch the new version',
292
- deadline: '2026-04-03',
293
- parentGoalId: null,
294
- childOrder: 0,
295
- isCompleted: false,
296
- completedAt: null,
297
- responsibleUid: null,
298
- isDeleted: false,
299
- progress: {
300
- totalTaskCount: 5,
301
- completedTaskCount: 2,
302
- percentage: 40,
303
- },
304
- creatorUid: DEFAULT_USER_ID,
305
- createdAt: defaultDate(),
306
- updatedAt: defaultDate(),
307
- };
308
- exports.DEFAULT_GOAL_NO_PROGRESS = Object.assign(Object.assign({}, exports.DEFAULT_GOAL), { id: 'e5f6g7h8-e29b-41d4-a716-446655440001', progress: undefined });
309
285
  exports.DEFAULT_APP_ID = '42';
310
286
  exports.DEFAULT_INSTALLATION_ID = '1001';
311
287
  exports.DEFAULT_UI_EXTENSION_ID = '2002';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const vitest_1 = require("vitest");
4
+ // In production the transport uses undici's own `fetch` (paired with the
5
+ // dispatcher) so the request client and dispatcher stay on one undici version.
6
+ // MSW intercepts the *global* `fetch`, not that separate undici instance, so
7
+ // force the transport onto the global `fetch` for every test in the suite; MSW
8
+ // then intercepts requests as usual. The real undici transport is covered
9
+ // directly by `http-dispatcher.test.ts` and `fetch-with-retry.test.ts`, which
10
+ // opt out of this seam with `vi.unmock('./http-dispatcher')`.
11
+ //
12
+ // This lives in its own setup file (not `msw-setup.ts`) because a hoisted
13
+ // `vi.mock` in a module that also re-exports values corrupts those exports.
14
+ vitest_1.vi.mock('../transport/http-dispatcher', async (importOriginal) => {
15
+ const actual = await importOriginal();
16
+ return Object.assign(Object.assign({}, actual), { getDefaultTransport: vitest_1.vi.fn(async () => undefined) });
17
+ });
@@ -14,7 +14,7 @@ function sign(body, secret = exports.CLIENT_SECRET) {
14
14
  * Snake_case task payload matching the v1 webhook wire shape.
15
15
  */
16
16
  function rawTask(overrides = {}) {
17
- return Object.assign({ id: '6XR4GqQQCW6Gv9h4', user_id: '2671355', project_id: '6XR4H993xv8H5qCR', section_id: null, parent_id: null, added_by_uid: '2671355', assigned_by_uid: null, responsible_uid: null, labels: [], deadline: null, duration: null, is_collapsed: false, checked: false, is_deleted: false, added_at: '2025-02-10T10:33:38.000000Z', completed_at: null, completed_by_uid: null, updated_at: '2025-02-10T10:33:38.000000Z', due: null, priority: 1, child_order: 3, content: 'Buy Milk', description: '', note_count: 0, day_order: -1, goal_ids: [], url: 'https://app.todoist.com/app/task/6XR4GqQQCW6Gv9h4' }, overrides);
17
+ return Object.assign({ id: '6XR4GqQQCW6Gv9h4', user_id: '2671355', project_id: '6XR4H993xv8H5qCR', section_id: null, parent_id: null, added_by_uid: '2671355', assigned_by_uid: null, responsible_uid: null, labels: [], deadline: null, duration: null, is_collapsed: false, checked: false, is_deleted: false, added_at: '2025-02-10T10:33:38.000000Z', completed_at: null, completed_by_uid: null, updated_at: '2025-02-10T10:33:38.000000Z', due: null, priority: 1, child_order: 3, content: 'Buy Milk', description: '', note_count: 0, day_order: -1, url: 'https://app.todoist.com/app/task/6XR4GqQQCW6Gv9h4' }, overrides);
18
18
  }
19
19
  /**
20
20
  * Wraps an event's `event_data` in the snake_case envelope the backend sends
@@ -8,7 +8,6 @@ const billing_client_1 = require("./clients/billing-client");
8
8
  const comment_client_1 = require("./clients/comment-client");
9
9
  const email_client_1 = require("./clients/email-client");
10
10
  const folder_client_1 = require("./clients/folder-client");
11
- const goals_client_1 = require("./clients/goals-client");
12
11
  const id_mapping_client_1 = require("./clients/id-mapping-client");
13
12
  const insights_client_1 = require("./clients/insights-client");
14
13
  const label_client_1 = require("./clients/label-client");
@@ -63,7 +62,6 @@ class TodoistApi {
63
62
  this.activityClient = new activity_client_1.ActivityClient(clientDeps);
64
63
  this.productivityClient = new productivity_client_1.ProductivityClient(clientDeps);
65
64
  this.workspaceClient = new workspace_client_1.WorkspaceClient(clientDeps);
66
- this.goalsClient = new goals_client_1.GoalsClient(clientDeps);
67
65
  this.billingClient = new billing_client_1.BillingClient(clientDeps);
68
66
  this.appClient = new app_client_1.AppClient(clientDeps);
69
67
  this.uiExtensionClient = new ui_extension_client_1.UiExtensionClient(clientDeps);
@@ -951,105 +949,6 @@ class TodoistApi {
951
949
  async deleteFolder(id, requestId) {
952
950
  return this.folderClient.deleteFolder(id, requestId);
953
951
  }
954
- // ── Goals ──
955
- /**
956
- * Retrieves a paginated list of goals.
957
- *
958
- * @param args - Optional filters including owner type, workspace ID, cursor, and limit.
959
- * @returns A promise that resolves to a paginated list of goals.
960
- */
961
- async getGoals(args) {
962
- return this.goalsClient.getGoals(args);
963
- }
964
- /**
965
- * Searches for goals matching a query.
966
- *
967
- * @param args - Search parameters including query string and optional owner type.
968
- * @returns A promise that resolves to a paginated list of matching goals.
969
- */
970
- async searchGoals(args) {
971
- return this.goalsClient.searchGoals(args);
972
- }
973
- /**
974
- * Retrieves a single goal by its ID.
975
- *
976
- * @param id - The unique identifier of the goal.
977
- * @returns A promise that resolves to the goal.
978
- */
979
- async getGoal(id) {
980
- return this.goalsClient.getGoal(id);
981
- }
982
- /**
983
- * Creates a new goal.
984
- *
985
- * @param args - Goal attributes including name and optional workspace, description, deadline, and responsible user.
986
- * @param requestId - Optional custom identifier for the request.
987
- * @returns A promise that resolves to the created goal.
988
- */
989
- async addGoal(args, requestId) {
990
- return this.goalsClient.addGoal(args, requestId);
991
- }
992
- /**
993
- * Updates an existing goal.
994
- *
995
- * @param id - The unique identifier of the goal to update.
996
- * @param args - Attributes to update on the goal.
997
- * @param requestId - Optional custom identifier for the request.
998
- * @returns A promise that resolves to the updated goal.
999
- */
1000
- async updateGoal(id, args, requestId) {
1001
- return this.goalsClient.updateGoal(id, args, requestId);
1002
- }
1003
- /**
1004
- * Deletes a goal by its ID.
1005
- *
1006
- * @param id - The unique identifier of the goal to delete.
1007
- * @param requestId - Optional custom identifier for the request.
1008
- * @returns A promise that resolves to `true` if successful.
1009
- */
1010
- async deleteGoal(id, requestId) {
1011
- return this.goalsClient.deleteGoal(id, requestId);
1012
- }
1013
- /**
1014
- * Marks a goal as complete.
1015
- *
1016
- * @param id - The unique identifier of the goal to complete.
1017
- * @param requestId - Optional custom identifier for the request.
1018
- * @returns A promise that resolves to the updated goal.
1019
- */
1020
- async completeGoal(id, requestId) {
1021
- return this.goalsClient.completeGoal(id, requestId);
1022
- }
1023
- /**
1024
- * Marks a previously completed goal as incomplete.
1025
- *
1026
- * @param id - The unique identifier of the goal to uncomplete.
1027
- * @param requestId - Optional custom identifier for the request.
1028
- * @returns A promise that resolves to the updated goal.
1029
- */
1030
- async uncompleteGoal(id, requestId) {
1031
- return this.goalsClient.uncompleteGoal(id, requestId);
1032
- }
1033
- /**
1034
- * Links a task to a goal so it contributes to goal progress.
1035
- *
1036
- * @param args - The goal ID and task ID to link.
1037
- * @param requestId - Optional custom identifier for the request.
1038
- * @returns A promise that resolves to the updated goal.
1039
- */
1040
- async linkTaskToGoal(args, requestId) {
1041
- return this.goalsClient.linkTaskToGoal(args, requestId);
1042
- }
1043
- /**
1044
- * Unlinks a previously linked task from a goal.
1045
- *
1046
- * @param args - The goal ID and task ID to unlink.
1047
- * @param requestId - Optional custom identifier for the request.
1048
- * @returns A promise that resolves to `true` if successful.
1049
- */
1050
- async unlinkTaskFromGoal(args, requestId) {
1051
- return this.goalsClient.unlinkTaskFromGoal(args, requestId);
1052
- }
1053
952
  // ── Billing ──
1054
953
  /**
1055
954
  * Retrieves the current user's subscription state.
@@ -99,6 +99,7 @@ function convertResponseToCustomFetch(response) {
99
99
  * Performs a fetch request with retry logic and timeout support
100
100
  */
101
101
  async function fetchWithRetry(args) {
102
+ var _a;
102
103
  const { url, options = {}, retryConfig = {}, customFetch } = args;
103
104
  const config = Object.assign(Object.assign({}, DEFAULT_RETRY_CONFIG), retryConfig);
104
105
  const { timeout, signal: userSignal } = options, fetchOptions = __rest(options, ["timeout", "signal"]);
@@ -120,13 +121,24 @@ async function fetchWithRetry(args) {
120
121
  fetchResponse = await customFetch(url, Object.assign(Object.assign({}, fetchOptions), { signal: requestSignal, timeout }));
121
122
  }
122
123
  else {
123
- const dispatcher = await (0, http_dispatcher_1.getDefaultDispatcher)();
124
+ // Read the dispatcher and its paired `fetch` as one value so
125
+ // they can never be mismatched. On Node, `fetch` is undici's
126
+ // own — paired with the dispatcher — so the request client and
127
+ // dispatcher stay on one undici version; otherwise the
128
+ // `decompress` interceptor terminates gzip responses when the
129
+ // global `fetch`'s bundled undici differs. Browser/edge (and
130
+ // Bun) have no paired `fetch` and fall back to the global one.
131
+ const transport = await (0, http_dispatcher_1.getDefaultTransport)();
124
132
  const nativeFetchOptions = Object.assign(Object.assign({}, fetchOptions), { signal: requestSignal });
125
- if (dispatcher !== undefined) {
133
+ if ((transport === null || transport === void 0 ? void 0 : transport.dispatcher) !== undefined) {
126
134
  // @ts-expect-error - dispatcher is a valid option for Node.js fetch but not in the TS types
127
- nativeFetchOptions.dispatcher = dispatcher;
135
+ nativeFetchOptions.dispatcher = transport.dispatcher;
128
136
  }
129
- const nativeResponse = await fetch(url, nativeFetchOptions);
137
+ // undici's `fetch` and the global `fetch` are the same function
138
+ // at runtime but carry different (undici vs DOM) types. Call
139
+ // through the global signature, which matches the options above.
140
+ const fetchImpl = ((_a = transport === null || transport === void 0 ? void 0 : transport.fetch) !== null && _a !== void 0 ? _a : fetch);
141
+ const nativeResponse = await fetchImpl(url, nativeFetchOptions);
130
142
  fetchResponse = convertResponseToCustomFetch(nativeResponse);
131
143
  }
132
144
  // Check if the response is successful
@@ -148,13 +160,13 @@ async function fetchWithRetry(args) {
148
160
  try {
149
161
  responseData = responseText ? JSON.parse(responseText) : undefined;
150
162
  }
151
- catch (_a) {
163
+ catch (_b) {
152
164
  responseData = responseText;
153
165
  }
154
166
  error.data = responseData;
155
167
  error.response.data = responseData;
156
168
  }
157
- catch (_b) {
169
+ catch (_c) {
158
170
  // If we can't read the response body, that's OK
159
171
  }
160
172
  throw error;
@@ -165,7 +177,7 @@ async function fetchWithRetry(args) {
165
177
  try {
166
178
  data = responseText ? JSON.parse(responseText) : undefined;
167
179
  }
168
- catch (_c) {
180
+ catch (_d) {
169
181
  // If JSON parsing fails, return the raw text
170
182
  data = responseText;
171
183
  }
@@ -33,7 +33,9 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.getDefaultTransport = getDefaultTransport;
36
37
  exports.getDefaultDispatcher = getDefaultDispatcher;
38
+ exports.getDefaultFetch = getDefaultFetch;
37
39
  exports.resetDefaultDispatcherForTests = resetDefaultDispatcherForTests;
38
40
  exports.suppressExperimentalWarningsSync = suppressExperimentalWarningsSync;
39
41
  // Use effectively-disabled keep-alive so short-lived CLI processes do not stay
@@ -42,32 +44,68 @@ const KEEP_ALIVE_OPTIONS = {
42
44
  keepAliveTimeout: 1,
43
45
  keepAliveMaxTimeout: 1,
44
46
  };
45
- let defaultDispatcherPromise;
46
- function getDefaultDispatcher() {
47
+ let defaultTransport;
48
+ let defaultTransportPromise;
49
+ /**
50
+ * The default dispatcher and its paired `fetch`, as a single value so the two
51
+ * are always read consistently. Resolves to `undefined` outside Node (browser/
52
+ * edge), where callers use the global `fetch` with no dispatcher.
53
+ */
54
+ function getDefaultTransport() {
47
55
  if (!isNodeEnvironment()) {
48
56
  return Promise.resolve(undefined);
49
57
  }
50
- if (!defaultDispatcherPromise) {
51
- defaultDispatcherPromise = createDefaultDispatcher().catch((error) => {
52
- defaultDispatcherPromise = undefined;
58
+ if (!defaultTransportPromise) {
59
+ defaultTransportPromise = createDefaultTransport()
60
+ .then((transport) => {
61
+ defaultTransport = transport;
62
+ return transport;
63
+ })
64
+ .catch((error) => {
65
+ defaultTransport = undefined;
66
+ defaultTransportPromise = undefined;
53
67
  throw error;
54
68
  });
55
69
  }
56
- return defaultDispatcherPromise;
70
+ return defaultTransportPromise;
71
+ }
72
+ async function getDefaultDispatcher() {
73
+ var _a;
74
+ return (_a = (await getDefaultTransport())) === null || _a === void 0 ? void 0 : _a.dispatcher;
75
+ }
76
+ /**
77
+ * The `fetch` implementation that must be used with the default dispatcher.
78
+ * Returns undici's own `fetch` on the full-undici Node path, or `undefined`
79
+ * (meaning: use the global `fetch`) in the browser/edge/Bun paths.
80
+ *
81
+ * Node's global `fetch` is backed by whatever undici version ships inside that
82
+ * Node release (6.x on Node 22 … 8.x on Node 26). Our dispatcher — and its
83
+ * `decompress` interceptor — comes from the npm `undici` package, which is a
84
+ * different version. Handing an npm-undici dispatcher to a mismatched built-in
85
+ * client makes gzip responses fail mid-stream with `terminated`. Sourcing
86
+ * `fetch` from the same npm `undici` keeps the whole request path on one
87
+ * version and removes the split.
88
+ *
89
+ * Only meaningful after {@link getDefaultTransport} has resolved, which is the
90
+ * one place that populates it.
91
+ */
92
+ function getDefaultFetch() {
93
+ return defaultTransport === null || defaultTransport === void 0 ? void 0 : defaultTransport.fetch;
57
94
  }
58
95
  async function resetDefaultDispatcherForTests() {
59
- if (!defaultDispatcherPromise) {
96
+ if (!defaultTransportPromise) {
60
97
  return;
61
98
  }
62
- const dispatcherPromise = defaultDispatcherPromise;
63
- defaultDispatcherPromise = undefined;
64
- await dispatcherPromise.then((dispatcher) => dispatcher.close(), () => undefined);
99
+ const transportPromise = defaultTransportPromise;
100
+ defaultTransport = undefined;
101
+ defaultTransportPromise = undefined;
102
+ await transportPromise.then((transport) => transport.dispatcher.close(), () => undefined);
65
103
  }
66
- async function createDefaultDispatcher() {
104
+ async function createDefaultTransport() {
67
105
  // Dynamic import so non-Node consumers (browser, edge runtimes) don't pull
68
- // undici into their bundle. `getDefaultDispatcher` already short-circuits
106
+ // undici into their bundle. `getDefaultTransport` already short-circuits
69
107
  // outside Node, so this branch only runs when undici is safe to load.
70
- const { EnvHttpProxyAgent, interceptors } = await Promise.resolve().then(() => __importStar(require('undici')));
108
+ const { EnvHttpProxyAgent, interceptors, fetch: undiciFetch } = await Promise.resolve().then(() => __importStar(require('undici')));
71
109
  const agent = new EnvHttpProxyAgent(KEEP_ALIVE_OPTIONS);
72
110
  // Some runtimes report `process.versions.node` (so `isNodeEnvironment()`
73
111
  // passes) but ship only a partial undici: `interceptors.decompress` is
@@ -76,7 +114,9 @@ async function createDefaultDispatcher() {
76
114
  // gzip/deflate/br/zstd natively — so skip the interceptor instead of
77
115
  // crashing on the missing API.
78
116
  if (typeof interceptors.decompress !== 'function') {
79
- return agent;
117
+ // Bun: pair the agent with the global `fetch` (undefined), which
118
+ // decompresses natively.
119
+ return { dispatcher: agent, fetch: undefined };
80
120
  }
81
121
  // Compose the response-decompression interceptor so gzip/deflate/br/zstd
82
122
  // bodies are decoded before consumers parse them. Required on Node 24+:
@@ -85,7 +125,12 @@ async function createDefaultDispatcher() {
85
125
  // so callers receive raw gzipped bytes and `JSON.parse` fails.
86
126
  // See https://github.com/Doist/todoist-cli/issues/318.
87
127
  const decompress = suppressExperimentalWarningsSync(() => interceptors.decompress());
88
- return agent.compose(decompress);
128
+ // Pair undici's own `fetch` with this dispatcher so the request client and
129
+ // the dispatcher stay on one undici version (see `getDefaultFetch`). The
130
+ // global `fetch` is backed by a different, Node-bundled undici; mixing the
131
+ // two makes the decompress interceptor terminate gzip responses on some
132
+ // Node versions.
133
+ return { dispatcher: agent.compose(decompress), fetch: undiciFetch };
89
134
  }
90
135
  // undici emits an `ExperimentalWarning` the first time `interceptors.decompress()`
91
136
  // runs. The interceptor is stable for our gzipped-JSON-over-HTTPS use case;
@@ -25,7 +25,6 @@ __exportStar(require("./productivity"), exports);
25
25
  __exportStar(require("./activity"), exports);
26
26
  __exportStar(require("./workspaces"), exports);
27
27
  __exportStar(require("./folders"), exports);
28
- __exportStar(require("./goals"), exports);
29
28
  __exportStar(require("./billing"), exports);
30
29
  __exportStar(require("./insights"), exports);
31
30
  __exportStar(require("./backups"), exports);
@@ -26,8 +26,6 @@ __exportStar(require("./reminders"), exports);
26
26
  __exportStar(require("./workspaces"), exports);
27
27
  __exportStar(require("./folders"), exports);
28
28
  __exportStar(require("./workspace-filters"), exports);
29
- __exportStar(require("./workspace-goals"), exports);
30
- __exportStar(require("./goals"), exports);
31
29
  __exportStar(require("./notifications"), exports);
32
30
  __exportStar(require("./sharing"), exports);
33
31
  __exportStar(require("./view-options"), exports);
@@ -31,8 +31,6 @@ exports.SYNC_RESOURCE_TYPES = [
31
31
  'project_view_options_defaults',
32
32
  'role_actions',
33
33
  'folders',
34
- 'workspace_goals',
35
- 'goals',
36
34
  'day_orders',
37
35
  'calendars',
38
36
  'calendar_accounts',
@@ -20,7 +20,6 @@ __exportStar(require("./folders"), exports);
20
20
  __exportStar(require("./tooltips"), exports);
21
21
  __exportStar(require("./notes"), exports);
22
22
  __exportStar(require("./workspace-filters"), exports);
23
- __exportStar(require("./workspace-goals"), exports);
24
23
  __exportStar(require("./calendars"), exports);
25
24
  __exportStar(require("./reminders"), exports);
26
25
  __exportStar(require("./completed-info"), exports);
@@ -2,12 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SyncResponseSchema = exports.SyncErrorSchema = void 0;
4
4
  const zod_1 = require("zod");
5
- const types_1 = require("../goals/types");
6
- const types_2 = require("../labels/types");
7
- const types_3 = require("../projects/types");
8
- const types_4 = require("../sections/types");
9
- const types_5 = require("../tasks/types");
10
- const types_6 = require("../workspaces/types");
5
+ const types_1 = require("../labels/types");
6
+ const types_2 = require("../projects/types");
7
+ const types_3 = require("../sections/types");
8
+ const types_4 = require("../tasks/types");
9
+ const types_5 = require("../workspaces/types");
11
10
  const resources_1 = require("./resources");
12
11
  exports.SyncErrorSchema = zod_1.z.object({
13
12
  error: zod_1.z.string(),
@@ -21,10 +20,10 @@ exports.SyncResponseSchema = zod_1.z.looseObject({
21
20
  fullSync: zod_1.z.boolean().optional(),
22
21
  syncStatus: zod_1.z.record(zod_1.z.string(), zod_1.z.union([zod_1.z.literal('ok'), exports.SyncErrorSchema])).optional(),
23
22
  tempIdMapping: zod_1.z.record(zod_1.z.string(), zod_1.z.string()).optional(),
24
- items: zod_1.z.array(types_5.TaskSchema).optional(),
25
- projects: zod_1.z.array(types_3.ProjectSchema).optional(),
26
- sections: zod_1.z.array(types_4.SectionSchema).optional(),
27
- labels: zod_1.z.array(types_2.LabelSchema).optional(),
23
+ items: zod_1.z.array(types_4.TaskSchema).optional(),
24
+ projects: zod_1.z.array(types_2.ProjectSchema).optional(),
25
+ sections: zod_1.z.array(types_3.SectionSchema).optional(),
26
+ labels: zod_1.z.array(types_1.LabelSchema).optional(),
28
27
  notes: zod_1.z.array(resources_1.NoteSchema).optional(),
29
28
  projectNotes: zod_1.z.array(resources_1.NoteSchema).optional(),
30
29
  filters: zod_1.z.array(resources_1.FilterSchema).optional(),
@@ -41,14 +40,12 @@ exports.SyncResponseSchema = zod_1.z.looseObject({
41
40
  completedInfo: zod_1.z.array(resources_1.CompletedInfoSchema).optional(),
42
41
  stats: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
43
42
  workspaces: zod_1.z.array(resources_1.SyncWorkspaceSchema).optional(),
44
- workspaceUsers: zod_1.z.array(types_6.WorkspaceUserSchema).optional(),
43
+ workspaceUsers: zod_1.z.array(types_5.WorkspaceUserSchema).optional(),
45
44
  workspaceFilters: zod_1.z.array(resources_1.WorkspaceFilterSchema).optional(),
46
45
  viewOptions: zod_1.z.array(resources_1.ViewOptionsSchema).optional(),
47
46
  projectViewOptionsDefaults: zod_1.z.array(resources_1.ProjectViewOptionsDefaultsSchema).optional(),
48
47
  roleActions: zod_1.z.array(zod_1.z.record(zod_1.z.string(), zod_1.z.unknown())).optional(),
49
48
  folders: zod_1.z.array(resources_1.FolderSchema).optional(),
50
- goals: zod_1.z.array(types_1.GoalSchema).optional(),
51
- workspaceGoals: zod_1.z.array(resources_1.WorkspaceGoalSchema).optional(),
52
49
  dayOrders: zod_1.z.record(zod_1.z.string(), zod_1.z.number()).optional(),
53
50
  calendars: zod_1.z.array(resources_1.CalendarSchema).optional(),
54
51
  calendarAccounts: zod_1.z.array(resources_1.CalendarAccountSchema).optional(),