@doist/todoist-sdk 8.4.0-next.2 → 8.4.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 (40) hide show
  1. package/dist/cjs/consts/endpoints.js +1 -6
  2. package/dist/cjs/todoist-api.js +5 -128
  3. package/dist/cjs/types/index.js +0 -1
  4. package/dist/cjs/types/sync/commands/index.js +0 -1
  5. package/dist/cjs/types/sync/resource-types.js +0 -1
  6. package/dist/cjs/utils/index.js +1 -0
  7. package/dist/cjs/utils/project-helpers.js +20 -0
  8. package/dist/cjs/utils/validators.js +36 -57
  9. package/dist/esm/consts/endpoints.js +0 -5
  10. package/dist/esm/todoist-api.js +7 -130
  11. package/dist/esm/types/index.js +0 -1
  12. package/dist/esm/types/sync/commands/index.js +0 -1
  13. package/dist/esm/types/sync/resource-types.js +0 -1
  14. package/dist/esm/utils/index.js +1 -0
  15. package/dist/esm/utils/project-helpers.js +16 -0
  16. package/dist/esm/utils/validators.js +2 -21
  17. package/dist/types/consts/endpoints.d.ts +0 -5
  18. package/dist/types/todoist-api.d.ts +5 -11
  19. package/dist/types/types/index.d.ts +0 -1
  20. package/dist/types/types/sync/commands/index.d.ts +0 -9
  21. package/dist/types/types/sync/resource-types.d.ts +1 -1
  22. package/dist/types/types/sync/resources/view-options.d.ts +6 -6
  23. package/dist/types/types/sync/response.d.ts +0 -2
  24. package/dist/types/types/tasks/requests.d.ts +0 -1
  25. package/dist/types/utils/index.d.ts +1 -0
  26. package/dist/types/utils/project-helpers.d.ts +13 -0
  27. package/dist/types/utils/validators.d.ts +8 -68
  28. package/package.json +1 -1
  29. package/dist/cjs/types/goals/index.js +0 -18
  30. package/dist/cjs/types/goals/requests.js +0 -2
  31. package/dist/cjs/types/goals/types.js +0 -29
  32. package/dist/cjs/types/sync/commands/goals.js +0 -2
  33. package/dist/esm/types/goals/index.js +0 -2
  34. package/dist/esm/types/goals/requests.js +0 -1
  35. package/dist/esm/types/goals/types.js +0 -26
  36. package/dist/esm/types/sync/commands/goals.js +0 -1
  37. package/dist/types/types/goals/index.d.ts +0 -2
  38. package/dist/types/types/goals/requests.d.ts +0 -33
  39. package/dist/types/types/goals/types.d.ts +0 -41
  40. package/dist/types/types/sync/commands/goals.d.ts +0 -33
@@ -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.ENDPOINT_WORKSPACE_MEMBERS = 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.ENDPOINT_WORKSPACE_MEMBERS = 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.getAuthBaseUri = getAuthBaseUri;
7
7
  exports.getWorkspaceInvitationAcceptEndpoint = getWorkspaceInvitationAcceptEndpoint;
@@ -86,11 +86,6 @@ exports.ENDPOINT_GET_TOKEN = 'access_token';
86
86
  exports.ENDPOINT_REVOKE = 'revoke';
87
87
  exports.ENDPOINT_REGISTER = 'register';
88
88
  exports.ENDPOINT_REST_FOLDERS = 'folders';
89
- exports.ENDPOINT_REST_GOALS = 'goals';
90
- exports.ENDPOINT_REST_GOALS_SEARCH = exports.ENDPOINT_REST_GOALS + '/search';
91
- exports.GOAL_COMPLETE = 'complete';
92
- exports.GOAL_UNCOMPLETE = 'uncomplete';
93
- exports.GOAL_TASKS = 'items';
94
89
  // Workspace endpoints
95
90
  exports.ENDPOINT_REST_WORKSPACES = 'workspaces';
96
91
  exports.ENDPOINT_WORKSPACE_INVITATIONS = 'workspaces/invitations';
@@ -632,6 +632,11 @@ class TodoistApi {
632
632
  /**
633
633
  * Deletes a project by its ID.
634
634
  *
635
+ * If the project is a workspace project, it must have been
636
+ * archived first before it can be deleted, otherwise calling
637
+ * this function will result in an error. Personal projects can
638
+ * be deleted regardless of their archived status.
639
+ *
635
640
  * @param id - The unique identifier of the project to delete.
636
641
  * @param requestId - Optional custom identifier for the request.
637
642
  * @returns A promise that resolves to `true` if successful.
@@ -1914,134 +1919,6 @@ class TodoistApi {
1914
1919
  });
1915
1920
  return (0, http_client_1.isSuccess)(response);
1916
1921
  }
1917
- // ── Goals ──
1918
- async getGoals(args) {
1919
- const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
1920
- httpMethod: 'GET',
1921
- baseUri: this.syncApiBase,
1922
- relativePath: endpoints_1.ENDPOINT_REST_GOALS,
1923
- apiToken: this.authToken,
1924
- customFetch: this.customFetch,
1925
- payload: args,
1926
- });
1927
- return {
1928
- results: (0, validators_1.validateGoalArray)(results),
1929
- nextCursor,
1930
- };
1931
- }
1932
- async searchGoals(args) {
1933
- const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
1934
- httpMethod: 'GET',
1935
- baseUri: this.syncApiBase,
1936
- relativePath: endpoints_1.ENDPOINT_REST_GOALS_SEARCH,
1937
- apiToken: this.authToken,
1938
- customFetch: this.customFetch,
1939
- payload: args,
1940
- });
1941
- return {
1942
- results: (0, validators_1.validateGoalArray)(results),
1943
- nextCursor,
1944
- };
1945
- }
1946
- async getGoal(id) {
1947
- zod_1.z.string().parse(id);
1948
- const response = await (0, http_client_1.request)({
1949
- httpMethod: 'GET',
1950
- baseUri: this.syncApiBase,
1951
- relativePath: generatePath(endpoints_1.ENDPOINT_REST_GOALS, id),
1952
- apiToken: this.authToken,
1953
- customFetch: this.customFetch,
1954
- });
1955
- return (0, validators_1.validateGoal)(response.data);
1956
- }
1957
- async addGoal(args, requestId) {
1958
- const response = await (0, http_client_1.request)({
1959
- httpMethod: 'POST',
1960
- baseUri: this.syncApiBase,
1961
- relativePath: endpoints_1.ENDPOINT_REST_GOALS,
1962
- apiToken: this.authToken,
1963
- customFetch: this.customFetch,
1964
- payload: args,
1965
- requestId: requestId,
1966
- });
1967
- return (0, validators_1.validateGoal)(response.data);
1968
- }
1969
- async updateGoal(id, args, requestId) {
1970
- zod_1.z.string().parse(id);
1971
- const response = await (0, http_client_1.request)({
1972
- httpMethod: 'POST',
1973
- baseUri: this.syncApiBase,
1974
- relativePath: generatePath(endpoints_1.ENDPOINT_REST_GOALS, id),
1975
- apiToken: this.authToken,
1976
- customFetch: this.customFetch,
1977
- payload: args,
1978
- requestId: requestId,
1979
- });
1980
- return (0, validators_1.validateGoal)(response.data);
1981
- }
1982
- async deleteGoal(id, requestId) {
1983
- zod_1.z.string().parse(id);
1984
- const response = await (0, http_client_1.request)({
1985
- httpMethod: 'DELETE',
1986
- baseUri: this.syncApiBase,
1987
- relativePath: generatePath(endpoints_1.ENDPOINT_REST_GOALS, id),
1988
- apiToken: this.authToken,
1989
- customFetch: this.customFetch,
1990
- requestId: requestId,
1991
- });
1992
- return (0, http_client_1.isSuccess)(response);
1993
- }
1994
- async completeGoal(id, requestId) {
1995
- zod_1.z.string().parse(id);
1996
- const response = await (0, http_client_1.request)({
1997
- httpMethod: 'POST',
1998
- baseUri: this.syncApiBase,
1999
- relativePath: generatePath(endpoints_1.ENDPOINT_REST_GOALS, id, endpoints_1.GOAL_COMPLETE),
2000
- apiToken: this.authToken,
2001
- customFetch: this.customFetch,
2002
- requestId: requestId,
2003
- });
2004
- return (0, validators_1.validateGoal)(response.data);
2005
- }
2006
- async uncompleteGoal(id, requestId) {
2007
- zod_1.z.string().parse(id);
2008
- const response = await (0, http_client_1.request)({
2009
- httpMethod: 'POST',
2010
- baseUri: this.syncApiBase,
2011
- relativePath: generatePath(endpoints_1.ENDPOINT_REST_GOALS, id, endpoints_1.GOAL_UNCOMPLETE),
2012
- apiToken: this.authToken,
2013
- customFetch: this.customFetch,
2014
- requestId: requestId,
2015
- });
2016
- return (0, validators_1.validateGoal)(response.data);
2017
- }
2018
- async linkTaskToGoal({ goalId, taskId }, requestId) {
2019
- zod_1.z.string().parse(goalId);
2020
- zod_1.z.string().parse(taskId);
2021
- const response = await (0, http_client_1.request)({
2022
- httpMethod: 'POST',
2023
- baseUri: this.syncApiBase,
2024
- relativePath: generatePath(endpoints_1.ENDPOINT_REST_GOALS, goalId, endpoints_1.GOAL_TASKS),
2025
- apiToken: this.authToken,
2026
- customFetch: this.customFetch,
2027
- payload: { itemId: taskId },
2028
- requestId: requestId,
2029
- });
2030
- return (0, validators_1.validateGoal)(response.data);
2031
- }
2032
- async unlinkTaskFromGoal({ goalId, taskId }, requestId) {
2033
- zod_1.z.string().parse(goalId);
2034
- zod_1.z.string().parse(taskId);
2035
- const response = await (0, http_client_1.request)({
2036
- httpMethod: 'DELETE',
2037
- baseUri: this.syncApiBase,
2038
- relativePath: generatePath(endpoints_1.ENDPOINT_REST_GOALS, goalId, endpoints_1.GOAL_TASKS, taskId),
2039
- apiToken: this.authToken,
2040
- customFetch: this.customFetch,
2041
- requestId: requestId,
2042
- });
2043
- return (0, http_client_1.isSuccess)(response);
2044
- }
2045
1922
  // ── Backups ──
2046
1923
  /**
2047
1924
  * Retrieves a list of available backups.
@@ -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("./insights"), exports);
30
29
  __exportStar(require("./backups"), exports);
31
30
  __exportStar(require("./id-mappings"), exports);
@@ -27,7 +27,6 @@ __exportStar(require("./workspaces"), exports);
27
27
  __exportStar(require("./folders"), exports);
28
28
  __exportStar(require("./workspace-filters"), exports);
29
29
  __exportStar(require("./workspace-goals"), exports);
30
- __exportStar(require("./goals"), exports);
31
30
  __exportStar(require("./notifications"), exports);
32
31
  __exportStar(require("./sharing"), exports);
33
32
  __exportStar(require("./view-options"), exports);
@@ -32,7 +32,6 @@ exports.SYNC_RESOURCE_TYPES = [
32
32
  'role_actions',
33
33
  'folders',
34
34
  'workspace_goals',
35
- 'goals',
36
35
  'day_orders',
37
36
  'calendars',
38
37
  'calendar_accounts',
@@ -23,3 +23,4 @@ Object.defineProperty(exports, "getProjectUrl", { enumerable: true, get: functio
23
23
  Object.defineProperty(exports, "getSectionUrl", { enumerable: true, get: function () { return url_helpers_1.getSectionUrl; } });
24
24
  var sync_helpers_1 = require("./sync-helpers");
25
25
  Object.defineProperty(exports, "createCommand", { enumerable: true, get: function () { return sync_helpers_1.createCommand; } });
26
+ __exportStar(require("./project-helpers"), exports);
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isWorkspaceProject = isWorkspaceProject;
4
+ exports.isPersonalProject = isPersonalProject;
5
+ /**
6
+ * Type guard to check if a project is a workspace project.
7
+ * @param project The project to check
8
+ * @returns True if the project is a workspace project
9
+ */
10
+ function isWorkspaceProject(project) {
11
+ return 'workspaceId' in project;
12
+ }
13
+ /**
14
+ * Type guard to check if a project is a personal project.
15
+ * @param project The project to check
16
+ * @returns True if the project is a personal project
17
+ */
18
+ function isPersonalProject(project) {
19
+ return !isWorkspaceProject(project);
20
+ }
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateNote = exports.validateGoalArray = exports.validateGoal = exports.validateFolderArray = exports.validateFolder = exports.validateCollaboratorStateArray = exports.validateCollaboratorState = exports.validateCollaboratorArray = exports.validateCollaborator = exports.validateFilterArray = exports.validateFilter = exports.validateMovedIdArray = exports.validateMovedId = exports.validateIdMappingArray = exports.validateIdMapping = exports.validateBackupArray = exports.validateBackup = exports.validateWorkspaceInsights = exports.validateProjectProgress = exports.validateProjectHealthContext = exports.validateProjectHealth = exports.validateProjectActivityStats = exports.validateWorkspaceUserTaskArray = exports.validateWorkspaceUserTask = exports.validateMemberActivityInfoArray = exports.validateMemberActivityInfo = exports.validateWorkspaceArray = exports.validateWorkspace = exports.validateJoinWorkspaceResult = exports.validateWorkspacePlanDetails = exports.validateWorkspaceInvitationArray = exports.validateWorkspaceInvitation = exports.validateWorkspaceUser = exports.validateAttachment = exports.validateActivityEventArray = exports.validateActivityEvent = exports.validateCurrentUser = exports.validateProductivityStats = exports.validateUserArray = exports.validateUser = exports.validateCommentArray = exports.validateComment = exports.validateLabelArray = exports.validateLabel = exports.validateSectionArray = exports.validateSection = exports.validateWorkspaceProjectArray = exports.validateWorkspaceProject = exports.validateTaskArray = exports.validateTask = void 0;
4
- exports.validateSuggestionArray = exports.validateSuggestion = exports.validateUserSettings = exports.validateSyncUser = exports.validateSyncWorkspaceArray = exports.validateSyncWorkspace = exports.validateLiveNotificationArray = exports.validateLiveNotification = exports.validateUserPlanLimits = exports.validateProjectViewOptionsDefaultsArray = exports.validateProjectViewOptionsDefaults = exports.validateViewOptionsArray = exports.validateViewOptions = exports.validateCompletedInfoArray = exports.validateCompletedInfo = exports.validateLocationReminderArray = exports.validateLocationReminder = exports.validateReminderArray = exports.validateReminder = exports.validateCalendarAccountArray = exports.validateCalendarAccount = exports.validateCalendarArray = exports.validateCalendar = exports.validateWorkspaceGoalArray = exports.validateWorkspaceGoal = exports.validateWorkspaceFilterArray = exports.validateWorkspaceFilter = exports.validateTooltips = exports.validateNoteArray = void 0;
5
- exports.isWorkspaceProject = isWorkspaceProject;
6
- exports.isPersonalProject = isPersonalProject;
3
+ exports.validateTooltips = exports.validateNoteArray = exports.validateNote = exports.validateFolderArray = exports.validateFolder = exports.validateCollaboratorStateArray = exports.validateCollaboratorState = exports.validateCollaboratorArray = exports.validateCollaborator = exports.validateFilterArray = exports.validateFilter = exports.validateMovedIdArray = exports.validateMovedId = exports.validateIdMappingArray = exports.validateIdMapping = exports.validateBackupArray = exports.validateBackup = exports.validateWorkspaceInsights = exports.validateProjectProgress = exports.validateProjectHealthContext = exports.validateProjectHealth = exports.validateProjectActivityStats = exports.validateWorkspaceUserTaskArray = exports.validateWorkspaceUserTask = exports.validateMemberActivityInfoArray = exports.validateMemberActivityInfo = exports.validateWorkspaceArray = exports.validateWorkspace = exports.validateJoinWorkspaceResult = exports.validateWorkspacePlanDetails = exports.validateWorkspaceInvitationArray = exports.validateWorkspaceInvitation = exports.validateWorkspaceUser = exports.validateAttachment = exports.validateActivityEventArray = exports.validateActivityEvent = exports.validateCurrentUser = exports.validateProductivityStats = exports.validateUserArray = exports.validateUser = exports.validateCommentArray = exports.validateComment = exports.validateLabelArray = exports.validateLabel = exports.validateSectionArray = exports.validateSection = exports.validateWorkspaceProjectArray = exports.validateWorkspaceProject = exports.validateTaskArray = exports.validateTask = void 0;
4
+ exports.validateSuggestionArray = exports.validateSuggestion = exports.validateUserSettings = exports.validateSyncUser = exports.validateSyncWorkspaceArray = exports.validateSyncWorkspace = exports.validateLiveNotificationArray = exports.validateLiveNotification = exports.validateUserPlanLimits = exports.validateProjectViewOptionsDefaultsArray = exports.validateProjectViewOptionsDefaults = exports.validateViewOptionsArray = exports.validateViewOptions = exports.validateCompletedInfoArray = exports.validateCompletedInfo = exports.validateLocationReminderArray = exports.validateLocationReminder = exports.validateReminderArray = exports.validateReminder = exports.validateCalendarAccountArray = exports.validateCalendarAccount = exports.validateCalendarArray = exports.validateCalendar = exports.validateWorkspaceGoalArray = exports.validateWorkspaceGoal = exports.validateWorkspaceFilterArray = exports.validateWorkspaceFilter = void 0;
7
5
  exports.validateProject = validateProject;
8
6
  exports.validateProjectArray = validateProjectArray;
9
7
  exports.validateWorkspaceUserArray = validateWorkspaceUserArray;
@@ -11,16 +9,15 @@ exports.parseSyncResponse = parseSyncResponse;
11
9
  const types_1 = require("../types/activity/types");
12
10
  const types_2 = require("../types/backups/types");
13
11
  const types_3 = require("../types/comments/types");
14
- const types_4 = require("../types/goals/types");
15
- const types_5 = require("../types/id-mappings/types");
16
- const types_6 = require("../types/insights/types");
17
- const types_7 = require("../types/labels/types");
18
- const types_8 = require("../types/productivity/types");
19
- const types_9 = require("../types/projects/types");
20
- const types_10 = require("../types/sections/types");
21
- const types_11 = require("../types/tasks/types");
22
- const types_12 = require("../types/users/types");
23
- const types_13 = require("../types/workspaces/types");
12
+ const types_4 = require("../types/id-mappings/types");
13
+ const types_5 = require("../types/insights/types");
14
+ const types_6 = require("../types/labels/types");
15
+ const types_7 = require("../types/productivity/types");
16
+ const types_8 = require("../types/projects/types");
17
+ const types_9 = require("../types/sections/types");
18
+ const types_10 = require("../types/tasks/types");
19
+ const types_11 = require("../types/users/types");
20
+ const types_12 = require("../types/workspaces/types");
24
21
  const resources_1 = require("../types/sync/resources");
25
22
  function createValidator(schema) {
26
23
  return (input) => schema.parse(input);
@@ -34,24 +31,8 @@ function createArrayValidator(validateItem) {
34
31
  };
35
32
  }
36
33
  // Entity validators
37
- exports.validateTask = createValidator(types_11.TaskSchema);
34
+ exports.validateTask = createValidator(types_10.TaskSchema);
38
35
  exports.validateTaskArray = createArrayValidator(exports.validateTask);
39
- /**
40
- * Type guard to check if a project is a workspace project.
41
- * @param project The project to check
42
- * @returns True if the project is a workspace project
43
- */
44
- function isWorkspaceProject(project) {
45
- return 'workspaceId' in project;
46
- }
47
- /**
48
- * Type guard to check if a project is a personal project.
49
- * @param project The project to check
50
- * @returns True if the project is a personal project
51
- */
52
- function isPersonalProject(project) {
53
- return !isWorkspaceProject(project);
54
- }
55
36
  /**
56
37
  * Validates and parses a project input.
57
38
  * @param input The input to validate
@@ -59,9 +40,9 @@ function isPersonalProject(project) {
59
40
  */
60
41
  function validateProject(input) {
61
42
  if ('workspaceId' in input) {
62
- return types_9.WorkspaceProjectSchema.parse(input);
43
+ return types_8.WorkspaceProjectSchema.parse(input);
63
44
  }
64
- return types_9.PersonalProjectSchema.parse(input);
45
+ return types_8.PersonalProjectSchema.parse(input);
65
46
  }
66
47
  function validateProjectArray(input) {
67
48
  if (!Array.isArray(input)) {
@@ -69,48 +50,48 @@ function validateProjectArray(input) {
69
50
  }
70
51
  return input.map(validateProject);
71
52
  }
72
- exports.validateWorkspaceProject = createValidator(types_9.WorkspaceProjectSchema);
53
+ exports.validateWorkspaceProject = createValidator(types_8.WorkspaceProjectSchema);
73
54
  exports.validateWorkspaceProjectArray = createArrayValidator(exports.validateWorkspaceProject);
74
- exports.validateSection = createValidator(types_10.SectionSchema);
55
+ exports.validateSection = createValidator(types_9.SectionSchema);
75
56
  exports.validateSectionArray = createArrayValidator(exports.validateSection);
76
- exports.validateLabel = createValidator(types_7.LabelSchema);
57
+ exports.validateLabel = createValidator(types_6.LabelSchema);
77
58
  exports.validateLabelArray = createArrayValidator(exports.validateLabel);
78
59
  exports.validateComment = createValidator(types_3.CommentSchema);
79
60
  exports.validateCommentArray = createArrayValidator(exports.validateComment);
80
- exports.validateUser = createValidator(types_12.UserSchema);
61
+ exports.validateUser = createValidator(types_11.UserSchema);
81
62
  exports.validateUserArray = createArrayValidator(exports.validateUser);
82
- exports.validateProductivityStats = createValidator(types_8.ProductivityStatsSchema);
83
- exports.validateCurrentUser = createValidator(types_12.CurrentUserSchema);
63
+ exports.validateProductivityStats = createValidator(types_7.ProductivityStatsSchema);
64
+ exports.validateCurrentUser = createValidator(types_11.CurrentUserSchema);
84
65
  exports.validateActivityEvent = createValidator(types_1.ActivityEventSchema);
85
66
  exports.validateActivityEventArray = createArrayValidator(exports.validateActivityEvent);
86
67
  exports.validateAttachment = createValidator(types_3.AttachmentSchema);
87
- exports.validateWorkspaceUser = createValidator(types_13.WorkspaceUserSchema);
68
+ exports.validateWorkspaceUser = createValidator(types_12.WorkspaceUserSchema);
88
69
  function validateWorkspaceUserArray(input) {
89
70
  if (!Array.isArray(input)) {
90
71
  throw new Error(`Expected array for workspace users, got ${typeof input}`);
91
72
  }
92
73
  return input.map(exports.validateWorkspaceUser);
93
74
  }
94
- exports.validateWorkspaceInvitation = createValidator(types_13.WorkspaceInvitationSchema);
75
+ exports.validateWorkspaceInvitation = createValidator(types_12.WorkspaceInvitationSchema);
95
76
  exports.validateWorkspaceInvitationArray = createArrayValidator(exports.validateWorkspaceInvitation);
96
- exports.validateWorkspacePlanDetails = createValidator(types_13.WorkspacePlanDetailsSchema);
97
- exports.validateJoinWorkspaceResult = createValidator(types_13.JoinWorkspaceResultSchema);
98
- exports.validateWorkspace = createValidator(types_13.WorkspaceSchema);
77
+ exports.validateWorkspacePlanDetails = createValidator(types_12.WorkspacePlanDetailsSchema);
78
+ exports.validateJoinWorkspaceResult = createValidator(types_12.JoinWorkspaceResultSchema);
79
+ exports.validateWorkspace = createValidator(types_12.WorkspaceSchema);
99
80
  exports.validateWorkspaceArray = createArrayValidator(exports.validateWorkspace);
100
- exports.validateMemberActivityInfo = createValidator(types_13.MemberActivityInfoSchema);
81
+ exports.validateMemberActivityInfo = createValidator(types_12.MemberActivityInfoSchema);
101
82
  exports.validateMemberActivityInfoArray = createArrayValidator(exports.validateMemberActivityInfo);
102
- exports.validateWorkspaceUserTask = createValidator(types_13.WorkspaceUserTaskSchema);
83
+ exports.validateWorkspaceUserTask = createValidator(types_12.WorkspaceUserTaskSchema);
103
84
  exports.validateWorkspaceUserTaskArray = createArrayValidator(exports.validateWorkspaceUserTask);
104
- exports.validateProjectActivityStats = createValidator(types_6.ProjectActivityStatsSchema);
105
- exports.validateProjectHealth = createValidator(types_6.ProjectHealthSchema);
106
- exports.validateProjectHealthContext = createValidator(types_6.ProjectHealthContextSchema);
107
- exports.validateProjectProgress = createValidator(types_6.ProjectProgressSchema);
108
- exports.validateWorkspaceInsights = createValidator(types_6.WorkspaceInsightsSchema);
85
+ exports.validateProjectActivityStats = createValidator(types_5.ProjectActivityStatsSchema);
86
+ exports.validateProjectHealth = createValidator(types_5.ProjectHealthSchema);
87
+ exports.validateProjectHealthContext = createValidator(types_5.ProjectHealthContextSchema);
88
+ exports.validateProjectProgress = createValidator(types_5.ProjectProgressSchema);
89
+ exports.validateWorkspaceInsights = createValidator(types_5.WorkspaceInsightsSchema);
109
90
  exports.validateBackup = createValidator(types_2.BackupSchema);
110
91
  exports.validateBackupArray = createArrayValidator(exports.validateBackup);
111
- exports.validateIdMapping = createValidator(types_5.IdMappingSchema);
92
+ exports.validateIdMapping = createValidator(types_4.IdMappingSchema);
112
93
  exports.validateIdMappingArray = createArrayValidator(exports.validateIdMapping);
113
- exports.validateMovedId = createValidator(types_5.MovedIdSchema);
94
+ exports.validateMovedId = createValidator(types_4.MovedIdSchema);
114
95
  exports.validateMovedIdArray = createArrayValidator(exports.validateMovedId);
115
96
  // Sync resource validators
116
97
  exports.validateFilter = createValidator(resources_1.FilterSchema);
@@ -121,8 +102,6 @@ exports.validateCollaboratorState = createValidator(resources_1.CollaboratorStat
121
102
  exports.validateCollaboratorStateArray = createArrayValidator(exports.validateCollaboratorState);
122
103
  exports.validateFolder = createValidator(resources_1.FolderSchema);
123
104
  exports.validateFolderArray = createArrayValidator(exports.validateFolder);
124
- exports.validateGoal = createValidator(types_4.GoalSchema);
125
- exports.validateGoalArray = createArrayValidator(exports.validateGoal);
126
105
  exports.validateNote = createValidator(resources_1.NoteSchema);
127
106
  exports.validateNoteArray = createArrayValidator(exports.validateNote);
128
107
  exports.validateTooltips = createValidator(resources_1.TooltipsSchema);
@@ -154,7 +133,7 @@ exports.validateUserSettings = createValidator(resources_1.UserSettingsSchema);
154
133
  exports.validateSuggestion = createValidator(resources_1.SuggestionSchema);
155
134
  exports.validateSuggestionArray = createArrayValidator(exports.validateSuggestion);
156
135
  function parseSyncResponse(raw) {
157
- return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, raw), ('items' in raw ? { items: (0, exports.validateTaskArray)(raw.items) } : {})), ('projects' in raw ? { projects: validateProjectArray(raw.projects) } : {})), ('sections' in raw ? { sections: (0, exports.validateSectionArray)(raw.sections) } : {})), ('labels' in raw ? { labels: (0, exports.validateLabelArray)(raw.labels) } : {})), ('notes' in raw ? { notes: (0, exports.validateNoteArray)(raw.notes) } : {})), ('projectNotes' in raw ? { projectNotes: (0, exports.validateNoteArray)(raw.projectNotes) } : {})), ('filters' in raw ? { filters: (0, exports.validateFilterArray)(raw.filters) } : {})), ('reminders' in raw ? { reminders: (0, exports.validateReminderArray)(raw.reminders) } : {})), ('remindersLocation' in raw
136
+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, raw), ('items' in raw ? { items: (0, exports.validateTaskArray)(raw.items) } : {})), ('projects' in raw ? { projects: validateProjectArray(raw.projects) } : {})), ('sections' in raw ? { sections: (0, exports.validateSectionArray)(raw.sections) } : {})), ('labels' in raw ? { labels: (0, exports.validateLabelArray)(raw.labels) } : {})), ('notes' in raw ? { notes: (0, exports.validateNoteArray)(raw.notes) } : {})), ('projectNotes' in raw ? { projectNotes: (0, exports.validateNoteArray)(raw.projectNotes) } : {})), ('filters' in raw ? { filters: (0, exports.validateFilterArray)(raw.filters) } : {})), ('reminders' in raw ? { reminders: (0, exports.validateReminderArray)(raw.reminders) } : {})), ('remindersLocation' in raw
158
137
  ? { remindersLocation: (0, exports.validateLocationReminderArray)(raw.remindersLocation) }
159
138
  : {})), ('user' in raw ? { user: (0, exports.validateSyncUser)(raw.user) } : {})), ('liveNotifications' in raw
160
139
  ? { liveNotifications: (0, exports.validateLiveNotificationArray)(raw.liveNotifications) }
@@ -174,7 +153,7 @@ function parseSyncResponse(raw) {
174
153
  ? {
175
154
  projectViewOptionsDefaults: (0, exports.validateProjectViewOptionsDefaultsArray)(raw.projectViewOptionsDefaults),
176
155
  }
177
- : {})), ('folders' in raw ? { folders: (0, exports.validateFolderArray)(raw.folders) } : {})), ('goals' in raw ? { goals: (0, exports.validateGoalArray)(raw.goals) } : {})), ('workspaceGoals' in raw
156
+ : {})), ('folders' in raw ? { folders: (0, exports.validateFolderArray)(raw.folders) } : {})), ('workspaceGoals' in raw
178
157
  ? { workspaceGoals: (0, exports.validateWorkspaceGoalArray)(raw.workspaceGoals) }
179
158
  : {})), ('calendars' in raw ? { calendars: (0, exports.validateCalendarArray)(raw.calendars) } : {})), ('calendarAccounts' in raw
180
159
  ? { calendarAccounts: (0, exports.validateCalendarAccountArray)(raw.calendarAccounts) }
@@ -67,11 +67,6 @@ export const ENDPOINT_GET_TOKEN = 'access_token';
67
67
  export const ENDPOINT_REVOKE = 'revoke';
68
68
  export const ENDPOINT_REGISTER = 'register';
69
69
  export const ENDPOINT_REST_FOLDERS = 'folders';
70
- export const ENDPOINT_REST_GOALS = 'goals';
71
- export const ENDPOINT_REST_GOALS_SEARCH = ENDPOINT_REST_GOALS + '/search';
72
- export const GOAL_COMPLETE = 'complete';
73
- export const GOAL_UNCOMPLETE = 'uncomplete';
74
- export const GOAL_TASKS = 'items';
75
70
  // Workspace endpoints
76
71
  export const ENDPOINT_REST_WORKSPACES = 'workspaces';
77
72
  export const ENDPOINT_WORKSPACE_INVITATIONS = 'workspaces/invitations';
@@ -10,7 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import { z } from 'zod';
13
- import { getSyncBaseUri, ENDPOINT_REST_TASKS, ENDPOINT_REST_TASKS_FILTER, ENDPOINT_REST_TASKS_COMPLETED_BY_COMPLETION_DATE, ENDPOINT_REST_TASKS_COMPLETED_BY_DUE_DATE, ENDPOINT_REST_TASKS_COMPLETED_SEARCH, ENDPOINT_REST_TASKS_COMPLETED, ENDPOINT_REST_TEMPLATES_FILE, ENDPOINT_REST_TEMPLATES_URL, ENDPOINT_REST_TEMPLATES_CREATE_FROM_FILE, ENDPOINT_REST_TEMPLATES_IMPORT_FROM_FILE, ENDPOINT_REST_TEMPLATES_IMPORT_FROM_ID, ENDPOINT_REST_PROJECTS, ENDPOINT_REST_PROJECTS_SEARCH, ENDPOINT_SYNC_QUICK_ADD, ENDPOINT_REST_TASK_CLOSE, ENDPOINT_REST_TASK_REOPEN, ENDPOINT_REST_TASK_MOVE, ENDPOINT_REST_LABELS, ENDPOINT_REST_LABELS_SEARCH, ENDPOINT_REST_PROJECT_COLLABORATORS, ENDPOINT_REST_SECTIONS, ENDPOINT_REST_SECTIONS_SEARCH, ENDPOINT_REST_COMMENTS, ENDPOINT_REST_LOCATION_REMINDERS, ENDPOINT_REST_REMINDERS, ENDPOINT_REST_LABELS_SHARED, ENDPOINT_REST_LABELS_SHARED_RENAME, ENDPOINT_REST_LABELS_SHARED_REMOVE, ENDPOINT_SYNC, PROJECT_ARCHIVE, PROJECT_UNARCHIVE, ENDPOINT_REST_PROJECTS_MOVE_TO_WORKSPACE, ENDPOINT_REST_PROJECTS_MOVE_TO_PERSONAL, ENDPOINT_REST_PROJECTS_ARCHIVED, ENDPOINT_REST_PROJECTS_ARCHIVED_COUNT, ENDPOINT_REST_PROJECTS_PERMISSIONS, ENDPOINT_REST_PROJECT_FULL, ENDPOINT_REST_PROJECT_JOIN, SECTION_ARCHIVE, SECTION_UNARCHIVE, ENDPOINT_REST_USER, ENDPOINT_REST_PRODUCTIVITY, ENDPOINT_REST_ACTIVITIES, ENDPOINT_REST_UPLOADS, getProjectInsightsActivityStatsEndpoint, getProjectInsightsHealthEndpoint, getProjectInsightsHealthContextEndpoint, getProjectInsightsProgressEndpoint, getProjectInsightsHealthAnalyzeEndpoint, getWorkspaceInsightsEndpoint, ENDPOINT_REST_BACKUPS, ENDPOINT_REST_BACKUPS_DOWNLOAD, ENDPOINT_REST_EMAILS, ENDPOINT_REST_ID_MAPPINGS, ENDPOINT_REST_MOVED_IDS, ENDPOINT_REST_WORKSPACES, ENDPOINT_WORKSPACE_MEMBERS, getWorkspaceUserTasksEndpoint, getWorkspaceInviteUsersEndpoint, getWorkspaceUserEndpoint, ENDPOINT_WORKSPACE_INVITATIONS, ENDPOINT_WORKSPACE_INVITATIONS_ALL, ENDPOINT_WORKSPACE_INVITATIONS_DELETE, getWorkspaceInvitationAcceptEndpoint, getWorkspaceInvitationRejectEndpoint, ENDPOINT_WORKSPACE_JOIN, ENDPOINT_WORKSPACE_LOGO, ENDPOINT_WORKSPACE_PLAN_DETAILS, ENDPOINT_WORKSPACE_USERS, getWorkspaceActiveProjectsEndpoint, getWorkspaceArchivedProjectsEndpoint, ENDPOINT_REST_FOLDERS, ENDPOINT_REST_GOALS, ENDPOINT_REST_GOALS_SEARCH, GOAL_COMPLETE, GOAL_UNCOMPLETE, GOAL_TASKS, } from './consts/endpoints.js';
13
+ import { getSyncBaseUri, ENDPOINT_REST_TASKS, ENDPOINT_REST_TASKS_FILTER, ENDPOINT_REST_TASKS_COMPLETED_BY_COMPLETION_DATE, ENDPOINT_REST_TASKS_COMPLETED_BY_DUE_DATE, ENDPOINT_REST_TASKS_COMPLETED_SEARCH, ENDPOINT_REST_TASKS_COMPLETED, ENDPOINT_REST_TEMPLATES_FILE, ENDPOINT_REST_TEMPLATES_URL, ENDPOINT_REST_TEMPLATES_CREATE_FROM_FILE, ENDPOINT_REST_TEMPLATES_IMPORT_FROM_FILE, ENDPOINT_REST_TEMPLATES_IMPORT_FROM_ID, ENDPOINT_REST_PROJECTS, ENDPOINT_REST_PROJECTS_SEARCH, ENDPOINT_SYNC_QUICK_ADD, ENDPOINT_REST_TASK_CLOSE, ENDPOINT_REST_TASK_REOPEN, ENDPOINT_REST_TASK_MOVE, ENDPOINT_REST_LABELS, ENDPOINT_REST_LABELS_SEARCH, ENDPOINT_REST_PROJECT_COLLABORATORS, ENDPOINT_REST_SECTIONS, ENDPOINT_REST_SECTIONS_SEARCH, ENDPOINT_REST_COMMENTS, ENDPOINT_REST_LOCATION_REMINDERS, ENDPOINT_REST_REMINDERS, ENDPOINT_REST_LABELS_SHARED, ENDPOINT_REST_LABELS_SHARED_RENAME, ENDPOINT_REST_LABELS_SHARED_REMOVE, ENDPOINT_SYNC, PROJECT_ARCHIVE, PROJECT_UNARCHIVE, ENDPOINT_REST_PROJECTS_MOVE_TO_WORKSPACE, ENDPOINT_REST_PROJECTS_MOVE_TO_PERSONAL, ENDPOINT_REST_PROJECTS_ARCHIVED, ENDPOINT_REST_PROJECTS_ARCHIVED_COUNT, ENDPOINT_REST_PROJECTS_PERMISSIONS, ENDPOINT_REST_PROJECT_FULL, ENDPOINT_REST_PROJECT_JOIN, SECTION_ARCHIVE, SECTION_UNARCHIVE, ENDPOINT_REST_USER, ENDPOINT_REST_PRODUCTIVITY, ENDPOINT_REST_ACTIVITIES, ENDPOINT_REST_UPLOADS, getProjectInsightsActivityStatsEndpoint, getProjectInsightsHealthEndpoint, getProjectInsightsHealthContextEndpoint, getProjectInsightsProgressEndpoint, getProjectInsightsHealthAnalyzeEndpoint, getWorkspaceInsightsEndpoint, ENDPOINT_REST_BACKUPS, ENDPOINT_REST_BACKUPS_DOWNLOAD, ENDPOINT_REST_EMAILS, ENDPOINT_REST_ID_MAPPINGS, ENDPOINT_REST_MOVED_IDS, ENDPOINT_REST_WORKSPACES, ENDPOINT_WORKSPACE_MEMBERS, getWorkspaceUserTasksEndpoint, getWorkspaceInviteUsersEndpoint, getWorkspaceUserEndpoint, ENDPOINT_WORKSPACE_INVITATIONS, ENDPOINT_WORKSPACE_INVITATIONS_ALL, ENDPOINT_WORKSPACE_INVITATIONS_DELETE, getWorkspaceInvitationAcceptEndpoint, getWorkspaceInvitationRejectEndpoint, ENDPOINT_WORKSPACE_JOIN, ENDPOINT_WORKSPACE_LOGO, ENDPOINT_WORKSPACE_PLAN_DETAILS, ENDPOINT_WORKSPACE_USERS, getWorkspaceActiveProjectsEndpoint, getWorkspaceArchivedProjectsEndpoint, ENDPOINT_REST_FOLDERS, } from './consts/endpoints.js';
14
14
  import { request, isSuccess } from './transport/http-client.js';
15
15
  import { UpdateReminderArgsSchema, UpdateLocationReminderArgsSchema, ReminderIdSchema, } from './types/reminders/index.js';
16
16
  import { normalizeObjectEventTypeForApi, denormalizeObjectTypeFromApi, } from './utils/activity-helpers.js';
@@ -18,7 +18,7 @@ import { camelCaseKeys } from './utils/case-conversion.js';
18
18
  import { uploadMultipartFile } from './utils/multipart-upload.js';
19
19
  import { processTaskContent } from './utils/uncompletable-helpers.js';
20
20
  import { formatDateToYYYYMMDD } from './utils/url-helpers.js';
21
- import { validateAttachment, validateComment, validateCommentArray, validateCurrentUser, validateLabel, validateLabelArray, validateProject, validateProjectArray, validateSection, validateSectionArray, validateTask, validateTaskArray, validateUserArray, validateProductivityStats, validateReminder, validateReminderArray, validateLocationReminderArray, validateActivityEventArray, validateWorkspaceUserArray, validateWorkspaceInvitation, validateWorkspaceInvitationArray, validateWorkspacePlanDetails, validateJoinWorkspaceResult, validateWorkspace, validateWorkspaceArray, validateMemberActivityInfoArray, validateWorkspaceUserTaskArray, validateProjectActivityStats, validateProjectHealth, validateProjectHealthContext, validateProjectProgress, validateWorkspaceInsights, validateBackupArray, validateIdMappingArray, validateMovedIdArray, validateFolder, validateFolderArray, validateGoal, validateGoalArray, validateCollaboratorArray, validateCollaboratorStateArray, validateNoteArray, validateWorkspaceProject, validateWorkspaceProjectArray, parseSyncResponse, } from './utils/validators.js';
21
+ import { validateAttachment, validateComment, validateCommentArray, validateCurrentUser, validateLabel, validateLabelArray, validateProject, validateProjectArray, validateSection, validateSectionArray, validateTask, validateTaskArray, validateUserArray, validateProductivityStats, validateReminder, validateReminderArray, validateLocationReminderArray, validateActivityEventArray, validateWorkspaceUserArray, validateWorkspaceInvitation, validateWorkspaceInvitationArray, validateWorkspacePlanDetails, validateJoinWorkspaceResult, validateWorkspace, validateWorkspaceArray, validateMemberActivityInfoArray, validateWorkspaceUserTaskArray, validateProjectActivityStats, validateProjectHealth, validateProjectHealthContext, validateProjectProgress, validateWorkspaceInsights, validateBackupArray, validateIdMappingArray, validateMovedIdArray, validateFolder, validateFolderArray, validateCollaboratorArray, validateCollaboratorStateArray, validateNoteArray, validateWorkspaceProject, validateWorkspaceProjectArray, parseSyncResponse, } from './utils/validators.js';
22
22
  import { v4 as uuidv4 } from 'uuid';
23
23
  import { TodoistArgumentError, TodoistRequestError } from './types/index.js';
24
24
  import { DATE_FORMAT_TO_API, TIME_FORMAT_TO_API, DAY_OF_WEEK_TO_API, } from './types/sync/index.js';
@@ -629,6 +629,11 @@ export class TodoistApi {
629
629
  /**
630
630
  * Deletes a project by its ID.
631
631
  *
632
+ * If the project is a workspace project, it must have been
633
+ * archived first before it can be deleted, otherwise calling
634
+ * this function will result in an error. Personal projects can
635
+ * be deleted regardless of their archived status.
636
+ *
632
637
  * @param id - The unique identifier of the project to delete.
633
638
  * @param requestId - Optional custom identifier for the request.
634
639
  * @returns A promise that resolves to `true` if successful.
@@ -1911,134 +1916,6 @@ export class TodoistApi {
1911
1916
  });
1912
1917
  return isSuccess(response);
1913
1918
  }
1914
- // ── Goals ──
1915
- async getGoals(args) {
1916
- const { data: { results, nextCursor }, } = await request({
1917
- httpMethod: 'GET',
1918
- baseUri: this.syncApiBase,
1919
- relativePath: ENDPOINT_REST_GOALS,
1920
- apiToken: this.authToken,
1921
- customFetch: this.customFetch,
1922
- payload: args,
1923
- });
1924
- return {
1925
- results: validateGoalArray(results),
1926
- nextCursor,
1927
- };
1928
- }
1929
- async searchGoals(args) {
1930
- const { data: { results, nextCursor }, } = await request({
1931
- httpMethod: 'GET',
1932
- baseUri: this.syncApiBase,
1933
- relativePath: ENDPOINT_REST_GOALS_SEARCH,
1934
- apiToken: this.authToken,
1935
- customFetch: this.customFetch,
1936
- payload: args,
1937
- });
1938
- return {
1939
- results: validateGoalArray(results),
1940
- nextCursor,
1941
- };
1942
- }
1943
- async getGoal(id) {
1944
- z.string().parse(id);
1945
- const response = await request({
1946
- httpMethod: 'GET',
1947
- baseUri: this.syncApiBase,
1948
- relativePath: generatePath(ENDPOINT_REST_GOALS, id),
1949
- apiToken: this.authToken,
1950
- customFetch: this.customFetch,
1951
- });
1952
- return validateGoal(response.data);
1953
- }
1954
- async addGoal(args, requestId) {
1955
- const response = await request({
1956
- httpMethod: 'POST',
1957
- baseUri: this.syncApiBase,
1958
- relativePath: ENDPOINT_REST_GOALS,
1959
- apiToken: this.authToken,
1960
- customFetch: this.customFetch,
1961
- payload: args,
1962
- requestId: requestId,
1963
- });
1964
- return validateGoal(response.data);
1965
- }
1966
- async updateGoal(id, args, requestId) {
1967
- z.string().parse(id);
1968
- const response = await request({
1969
- httpMethod: 'POST',
1970
- baseUri: this.syncApiBase,
1971
- relativePath: generatePath(ENDPOINT_REST_GOALS, id),
1972
- apiToken: this.authToken,
1973
- customFetch: this.customFetch,
1974
- payload: args,
1975
- requestId: requestId,
1976
- });
1977
- return validateGoal(response.data);
1978
- }
1979
- async deleteGoal(id, requestId) {
1980
- z.string().parse(id);
1981
- const response = await request({
1982
- httpMethod: 'DELETE',
1983
- baseUri: this.syncApiBase,
1984
- relativePath: generatePath(ENDPOINT_REST_GOALS, id),
1985
- apiToken: this.authToken,
1986
- customFetch: this.customFetch,
1987
- requestId: requestId,
1988
- });
1989
- return isSuccess(response);
1990
- }
1991
- async completeGoal(id, requestId) {
1992
- z.string().parse(id);
1993
- const response = await request({
1994
- httpMethod: 'POST',
1995
- baseUri: this.syncApiBase,
1996
- relativePath: generatePath(ENDPOINT_REST_GOALS, id, GOAL_COMPLETE),
1997
- apiToken: this.authToken,
1998
- customFetch: this.customFetch,
1999
- requestId: requestId,
2000
- });
2001
- return validateGoal(response.data);
2002
- }
2003
- async uncompleteGoal(id, requestId) {
2004
- z.string().parse(id);
2005
- const response = await request({
2006
- httpMethod: 'POST',
2007
- baseUri: this.syncApiBase,
2008
- relativePath: generatePath(ENDPOINT_REST_GOALS, id, GOAL_UNCOMPLETE),
2009
- apiToken: this.authToken,
2010
- customFetch: this.customFetch,
2011
- requestId: requestId,
2012
- });
2013
- return validateGoal(response.data);
2014
- }
2015
- async linkTaskToGoal({ goalId, taskId }, requestId) {
2016
- z.string().parse(goalId);
2017
- z.string().parse(taskId);
2018
- const response = await request({
2019
- httpMethod: 'POST',
2020
- baseUri: this.syncApiBase,
2021
- relativePath: generatePath(ENDPOINT_REST_GOALS, goalId, GOAL_TASKS),
2022
- apiToken: this.authToken,
2023
- customFetch: this.customFetch,
2024
- payload: { itemId: taskId },
2025
- requestId: requestId,
2026
- });
2027
- return validateGoal(response.data);
2028
- }
2029
- async unlinkTaskFromGoal({ goalId, taskId }, requestId) {
2030
- z.string().parse(goalId);
2031
- z.string().parse(taskId);
2032
- const response = await request({
2033
- httpMethod: 'DELETE',
2034
- baseUri: this.syncApiBase,
2035
- relativePath: generatePath(ENDPOINT_REST_GOALS, goalId, GOAL_TASKS, taskId),
2036
- apiToken: this.authToken,
2037
- customFetch: this.customFetch,
2038
- requestId: requestId,
2039
- });
2040
- return isSuccess(response);
2041
- }
2042
1919
  // ── Backups ──
2043
1920
  /**
2044
1921
  * Retrieves a list of available backups.
@@ -9,7 +9,6 @@ export * from './productivity/index.js';
9
9
  export * from './activity/index.js';
10
10
  export * from './workspaces/index.js';
11
11
  export * from './folders/index.js';
12
- export * from './goals/index.js';
13
12
  export * from './insights/index.js';
14
13
  export * from './backups/index.js';
15
14
  export * from './id-mappings/index.js';
@@ -11,7 +11,6 @@ export * from './workspaces.js';
11
11
  export * from './folders.js';
12
12
  export * from './workspace-filters.js';
13
13
  export * from './workspace-goals.js';
14
- export * from './goals.js';
15
14
  export * from './notifications.js';
16
15
  export * from './sharing.js';
17
16
  export * from './view-options.js';
@@ -29,7 +29,6 @@ export const SYNC_RESOURCE_TYPES = [
29
29
  'role_actions',
30
30
  'folders',
31
31
  'workspace_goals',
32
- 'goals',
33
32
  'day_orders',
34
33
  'calendars',
35
34
  'calendar_accounts',
@@ -2,3 +2,4 @@ export * from './colors.js';
2
2
  export * from './sanitization.js';
3
3
  export { getTaskUrl, getProjectUrl, getSectionUrl } from './url-helpers.js';
4
4
  export { createCommand } from './sync-helpers.js';
5
+ export * from './project-helpers.js';
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Type guard to check if a project is a workspace project.
3
+ * @param project The project to check
4
+ * @returns True if the project is a workspace project
5
+ */
6
+ export function isWorkspaceProject(project) {
7
+ return 'workspaceId' in project;
8
+ }
9
+ /**
10
+ * Type guard to check if a project is a personal project.
11
+ * @param project The project to check
12
+ * @returns True if the project is a personal project
13
+ */
14
+ export function isPersonalProject(project) {
15
+ return !isWorkspaceProject(project);
16
+ }