@doist/todoist-sdk 10.1.0 → 10.2.0-next.1

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 (48) hide show
  1. package/dist/cjs/clients/goals-client.js +145 -0
  2. package/dist/cjs/consts/endpoints.js +6 -1
  3. package/dist/cjs/test-utils/test-defaults.js +26 -2
  4. package/dist/cjs/todoist-api.js +33 -0
  5. package/dist/cjs/types/goals/index.js +18 -0
  6. package/dist/cjs/types/goals/requests.js +2 -0
  7. package/dist/cjs/types/goals/types.js +56 -0
  8. package/dist/cjs/types/index.js +1 -0
  9. package/dist/cjs/types/sync/commands/goals.js +2 -0
  10. package/dist/cjs/types/sync/commands/index.js +1 -0
  11. package/dist/cjs/types/sync/resource-types.js +1 -0
  12. package/dist/cjs/types/sync/resources/user-settings.js +2 -2
  13. package/dist/cjs/types/sync/resources/user.js +4 -4
  14. package/dist/cjs/types/sync/response.js +12 -10
  15. package/dist/cjs/utils/validators.js +53 -51
  16. package/dist/esm/clients/goals-client.js +141 -0
  17. package/dist/esm/consts/endpoints.js +5 -0
  18. package/dist/esm/test-utils/test-defaults.js +24 -0
  19. package/dist/esm/todoist-api.js +33 -0
  20. package/dist/esm/types/goals/index.js +2 -0
  21. package/dist/esm/types/goals/requests.js +1 -0
  22. package/dist/esm/types/goals/types.js +53 -0
  23. package/dist/esm/types/index.js +1 -0
  24. package/dist/esm/types/sync/commands/goals.js +1 -0
  25. package/dist/esm/types/sync/commands/index.js +1 -0
  26. package/dist/esm/types/sync/resource-types.js +1 -0
  27. package/dist/esm/types/sync/resources/user-settings.js +2 -2
  28. package/dist/esm/types/sync/resources/user.js +4 -4
  29. package/dist/esm/types/sync/response.js +2 -0
  30. package/dist/esm/utils/validators.js +2 -0
  31. package/dist/types/clients/goals-client.d.ts +20 -0
  32. package/dist/types/consts/endpoints.d.ts +5 -0
  33. package/dist/types/test-utils/test-defaults.d.ts +4 -1
  34. package/dist/types/todoist-api.d.ts +12 -0
  35. package/dist/types/types/goals/index.d.ts +2 -0
  36. package/dist/types/types/goals/requests.d.ts +33 -0
  37. package/dist/types/types/goals/types.d.ts +51 -0
  38. package/dist/types/types/index.d.ts +1 -0
  39. package/dist/types/types/sync/commands/goals.d.ts +33 -0
  40. package/dist/types/types/sync/commands/index.d.ts +9 -0
  41. package/dist/types/types/sync/resource-types.d.ts +1 -1
  42. package/dist/types/types/sync/resources/user-settings.d.ts +2 -2
  43. package/dist/types/types/sync/resources/user.d.ts +4 -4
  44. package/dist/types/types/sync/resources/view-options.d.ts +6 -6
  45. package/dist/types/types/sync/response.d.ts +35 -10
  46. package/dist/types/types/tasks/requests.d.ts +1 -0
  47. package/dist/types/utils/validators.d.ts +60 -13
  48. package/package.json +1 -1
@@ -0,0 +1,145 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GoalsClient = void 0;
4
+ const zod_1 = require("zod");
5
+ const endpoints_1 = require("../consts/endpoints");
6
+ const http_client_1 = require("../transport/http-client");
7
+ const request_helpers_1 = require("../utils/request-helpers");
8
+ const validators_1 = require("../utils/validators");
9
+ const base_client_1 = require("./base-client");
10
+ /**
11
+ * Internal sub-client handling all goal-domain endpoints.
12
+ *
13
+ * Instantiated by `TodoistApi`; every public goal method on `TodoistApi`
14
+ * delegates here. See `todoist-api.ts` for the user-facing JSDoc.
15
+ */
16
+ class GoalsClient extends base_client_1.BaseClient {
17
+ async getGoals(args) {
18
+ const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
19
+ httpMethod: 'GET',
20
+ baseUri: this.syncApiBase,
21
+ relativePath: endpoints_1.ENDPOINT_REST_GOALS,
22
+ apiToken: this.authToken,
23
+ customFetch: this.customFetch,
24
+ payload: args,
25
+ });
26
+ return {
27
+ results: (0, validators_1.validateGoalArray)(results),
28
+ nextCursor,
29
+ };
30
+ }
31
+ async searchGoals(args) {
32
+ const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
33
+ httpMethod: 'GET',
34
+ baseUri: this.syncApiBase,
35
+ relativePath: endpoints_1.ENDPOINT_REST_GOALS_SEARCH,
36
+ apiToken: this.authToken,
37
+ customFetch: this.customFetch,
38
+ payload: args,
39
+ });
40
+ return {
41
+ results: (0, validators_1.validateGoalArray)(results),
42
+ nextCursor,
43
+ };
44
+ }
45
+ async getGoal(id) {
46
+ zod_1.z.string().parse(id);
47
+ const response = await (0, http_client_1.request)({
48
+ httpMethod: 'GET',
49
+ baseUri: this.syncApiBase,
50
+ relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_GOALS, id),
51
+ apiToken: this.authToken,
52
+ customFetch: this.customFetch,
53
+ });
54
+ return (0, validators_1.validateGoal)(response.data);
55
+ }
56
+ async addGoal(args, requestId) {
57
+ const response = await (0, http_client_1.request)({
58
+ httpMethod: 'POST',
59
+ baseUri: this.syncApiBase,
60
+ relativePath: endpoints_1.ENDPOINT_REST_GOALS,
61
+ apiToken: this.authToken,
62
+ customFetch: this.customFetch,
63
+ payload: args,
64
+ requestId: requestId,
65
+ });
66
+ return (0, validators_1.validateGoal)(response.data);
67
+ }
68
+ async updateGoal(id, args, requestId) {
69
+ zod_1.z.string().parse(id);
70
+ const response = await (0, http_client_1.request)({
71
+ httpMethod: 'POST',
72
+ baseUri: this.syncApiBase,
73
+ relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_GOALS, id),
74
+ apiToken: this.authToken,
75
+ customFetch: this.customFetch,
76
+ payload: args,
77
+ requestId: requestId,
78
+ });
79
+ return (0, validators_1.validateGoal)(response.data);
80
+ }
81
+ async deleteGoal(id, requestId) {
82
+ zod_1.z.string().parse(id);
83
+ const response = await (0, http_client_1.request)({
84
+ httpMethod: 'DELETE',
85
+ baseUri: this.syncApiBase,
86
+ relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_GOALS, id),
87
+ apiToken: this.authToken,
88
+ customFetch: this.customFetch,
89
+ requestId: requestId,
90
+ });
91
+ return (0, http_client_1.isSuccess)(response);
92
+ }
93
+ async completeGoal(id, requestId) {
94
+ zod_1.z.string().parse(id);
95
+ const response = await (0, http_client_1.request)({
96
+ httpMethod: 'POST',
97
+ baseUri: this.syncApiBase,
98
+ relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_GOALS, id, endpoints_1.GOAL_COMPLETE),
99
+ apiToken: this.authToken,
100
+ customFetch: this.customFetch,
101
+ requestId: requestId,
102
+ });
103
+ return (0, validators_1.validateGoal)(response.data);
104
+ }
105
+ async uncompleteGoal(id, requestId) {
106
+ zod_1.z.string().parse(id);
107
+ const response = await (0, http_client_1.request)({
108
+ httpMethod: 'POST',
109
+ baseUri: this.syncApiBase,
110
+ relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_GOALS, id, endpoints_1.GOAL_UNCOMPLETE),
111
+ apiToken: this.authToken,
112
+ customFetch: this.customFetch,
113
+ requestId: requestId,
114
+ });
115
+ return (0, validators_1.validateGoal)(response.data);
116
+ }
117
+ async linkTaskToGoal({ goalId, taskId }, requestId) {
118
+ zod_1.z.string().parse(goalId);
119
+ zod_1.z.string().parse(taskId);
120
+ const response = await (0, http_client_1.request)({
121
+ httpMethod: 'POST',
122
+ baseUri: this.syncApiBase,
123
+ relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_GOALS, goalId, endpoints_1.GOAL_TASKS),
124
+ apiToken: this.authToken,
125
+ customFetch: this.customFetch,
126
+ payload: { itemId: taskId },
127
+ requestId: requestId,
128
+ });
129
+ return (0, validators_1.validateGoal)(response.data);
130
+ }
131
+ async unlinkTaskFromGoal({ goalId, taskId }, requestId) {
132
+ zod_1.z.string().parse(goalId);
133
+ zod_1.z.string().parse(taskId);
134
+ const response = await (0, http_client_1.request)({
135
+ httpMethod: 'DELETE',
136
+ baseUri: this.syncApiBase,
137
+ relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_GOALS, goalId, endpoints_1.GOAL_TASKS, taskId),
138
+ apiToken: this.authToken,
139
+ customFetch: this.customFetch,
140
+ requestId: requestId,
141
+ });
142
+ return (0, http_client_1.isSuccess)(response);
143
+ }
144
+ }
145
+ exports.GoalsClient = GoalsClient;
@@ -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_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;
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_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;
5
5
  exports.getSyncBaseUri = getSyncBaseUri;
6
6
  exports.getApiRootBaseUri = getApiRootBaseUri;
7
7
  exports.getAuthBaseUri = getAuthBaseUri;
@@ -104,6 +104,11 @@ 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';
107
112
  // Workspace endpoints
108
113
  exports.ENDPOINT_REST_WORKSPACES = 'workspaces';
109
114
  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_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;
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;
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';
@@ -281,6 +281,30 @@ exports.DEFAULT_COLLABORATOR_STATE = {
281
281
  state: 'active',
282
282
  isDeleted: false,
283
283
  };
284
+ exports.DEFAULT_GOAL_ID = '550e8400-e29b-41d4-a716-446655440000';
285
+ exports.DEFAULT_GOAL = {
286
+ id: exports.DEFAULT_GOAL_ID,
287
+ ownerType: 'USER',
288
+ ownerId: DEFAULT_USER_ID,
289
+ name: 'Ship v2',
290
+ description: 'Launch the new version',
291
+ deadline: '2026-04-03',
292
+ parentGoalId: null,
293
+ childOrder: 0,
294
+ isCompleted: false,
295
+ completedAt: null,
296
+ responsibleUid: null,
297
+ isDeleted: false,
298
+ progress: {
299
+ totalTaskCount: 5,
300
+ completedTaskCount: 2,
301
+ percentage: 40,
302
+ },
303
+ creatorUid: DEFAULT_USER_ID,
304
+ createdAt: defaultDate(),
305
+ updatedAt: defaultDate(),
306
+ };
307
+ exports.DEFAULT_GOAL_NO_PROGRESS = Object.assign(Object.assign({}, exports.DEFAULT_GOAL), { id: 'e5f6g7h8-e29b-41d4-a716-446655440001', progress: undefined });
284
308
  exports.DEFAULT_APP_ID = '42';
285
309
  exports.DEFAULT_INSTALLATION_ID = '1001';
286
310
  exports.DEFAULT_UI_EXTENSION_ID = '2002';
@@ -7,6 +7,7 @@ const backup_client_1 = require("./clients/backup-client");
7
7
  const comment_client_1 = require("./clients/comment-client");
8
8
  const email_client_1 = require("./clients/email-client");
9
9
  const folder_client_1 = require("./clients/folder-client");
10
+ const goals_client_1 = require("./clients/goals-client");
10
11
  const id_mapping_client_1 = require("./clients/id-mapping-client");
11
12
  const insights_client_1 = require("./clients/insights-client");
12
13
  const label_client_1 = require("./clients/label-client");
@@ -61,6 +62,7 @@ class TodoistApi {
61
62
  this.activityClient = new activity_client_1.ActivityClient(clientDeps);
62
63
  this.productivityClient = new productivity_client_1.ProductivityClient(clientDeps);
63
64
  this.workspaceClient = new workspace_client_1.WorkspaceClient(clientDeps);
65
+ this.goalsClient = new goals_client_1.GoalsClient(clientDeps);
64
66
  this.appClient = new app_client_1.AppClient(clientDeps);
65
67
  this.uiExtensionClient = new ui_extension_client_1.UiExtensionClient(clientDeps);
66
68
  }
@@ -942,6 +944,37 @@ class TodoistApi {
942
944
  async deleteFolder(id, requestId) {
943
945
  return this.folderClient.deleteFolder(id, requestId);
944
946
  }
947
+ // ── Goals ──
948
+ async getGoals(args) {
949
+ return this.goalsClient.getGoals(args);
950
+ }
951
+ async searchGoals(args) {
952
+ return this.goalsClient.searchGoals(args);
953
+ }
954
+ async getGoal(id) {
955
+ return this.goalsClient.getGoal(id);
956
+ }
957
+ async addGoal(args, requestId) {
958
+ return this.goalsClient.addGoal(args, requestId);
959
+ }
960
+ async updateGoal(id, args, requestId) {
961
+ return this.goalsClient.updateGoal(id, args, requestId);
962
+ }
963
+ async deleteGoal(id, requestId) {
964
+ return this.goalsClient.deleteGoal(id, requestId);
965
+ }
966
+ async completeGoal(id, requestId) {
967
+ return this.goalsClient.completeGoal(id, requestId);
968
+ }
969
+ async uncompleteGoal(id, requestId) {
970
+ return this.goalsClient.uncompleteGoal(id, requestId);
971
+ }
972
+ async linkTaskToGoal(args, requestId) {
973
+ return this.goalsClient.linkTaskToGoal(args, requestId);
974
+ }
975
+ async unlinkTaskFromGoal(args, requestId) {
976
+ return this.goalsClient.unlinkTaskFromGoal(args, requestId);
977
+ }
945
978
  // ── Backups ──
946
979
  /**
947
980
  * Retrieves a list of available backups.
@@ -0,0 +1,18 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./types"), exports);
18
+ __exportStar(require("./requests"), exports);
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.GoalSchema = exports.GoalProgressSchema = exports.GOAL_OWNER_TYPES = void 0;
15
+ const zod_1 = require("zod");
16
+ /** Available goal owner types. */
17
+ exports.GOAL_OWNER_TYPES = ['USER', 'WORKSPACE'];
18
+ /**
19
+ * Progress of a {@link Goal}.
20
+ *
21
+ * The REST API returns these counts under `total_item_count` / `completed_item_count`,
22
+ * reflecting the backend's generic "item" terminology. The SDK normalizes them to
23
+ * `totalTaskCount` / `completedTaskCount` so the public surface consistently speaks
24
+ * in "tasks" (matching the rest of the SDK). The `preprocess` step below performs
25
+ * that rename after the transport layer's snake_case → camelCase conversion — do not
26
+ * remove it without also changing the downstream field names.
27
+ */
28
+ exports.GoalProgressSchema = zod_1.z.preprocess((raw) => {
29
+ if (raw === null || raw === undefined || typeof raw !== 'object' || Array.isArray(raw)) {
30
+ return raw;
31
+ }
32
+ const _a = raw, { totalItemCount, completedItemCount, totalTaskCount, completedTaskCount } = _a, rest = __rest(_a, ["totalItemCount", "completedItemCount", "totalTaskCount", "completedTaskCount"]);
33
+ return Object.assign(Object.assign({}, rest), { totalTaskCount: totalTaskCount !== null && totalTaskCount !== void 0 ? totalTaskCount : totalItemCount, completedTaskCount: completedTaskCount !== null && completedTaskCount !== void 0 ? completedTaskCount : completedItemCount });
34
+ }, zod_1.z.looseObject({
35
+ totalTaskCount: zod_1.z.number().int(),
36
+ completedTaskCount: zod_1.z.number().int(),
37
+ percentage: zod_1.z.number(),
38
+ }));
39
+ exports.GoalSchema = zod_1.z.looseObject({
40
+ id: zod_1.z.string(),
41
+ ownerType: zod_1.z.enum(exports.GOAL_OWNER_TYPES),
42
+ ownerId: zod_1.z.string(),
43
+ name: zod_1.z.string(),
44
+ description: zod_1.z.string().nullable(),
45
+ deadline: zod_1.z.string().nullable(),
46
+ parentGoalId: zod_1.z.string().nullable(),
47
+ childOrder: zod_1.z.number().int(),
48
+ isCompleted: zod_1.z.boolean(),
49
+ completedAt: zod_1.z.coerce.date().nullable(),
50
+ responsibleUid: zod_1.z.string().nullable(),
51
+ isDeleted: zod_1.z.boolean(),
52
+ progress: exports.GoalProgressSchema.optional(),
53
+ creatorUid: zod_1.z.string(),
54
+ createdAt: zod_1.z.coerce.date(),
55
+ updatedAt: zod_1.z.coerce.date(),
56
+ });
@@ -25,6 +25,7 @@ __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);
28
29
  __exportStar(require("./insights"), exports);
29
30
  __exportStar(require("./backups"), exports);
30
31
  __exportStar(require("./id-mappings"), exports);
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -27,6 +27,7 @@ __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);
30
31
  __exportStar(require("./notifications"), exports);
31
32
  __exportStar(require("./sharing"), exports);
32
33
  __exportStar(require("./view-options"), exports);
@@ -32,6 +32,7 @@ exports.SYNC_RESOURCE_TYPES = [
32
32
  'role_actions',
33
33
  'folders',
34
34
  'workspace_goals',
35
+ 'goals',
35
36
  'day_orders',
36
37
  'calendars',
37
38
  'calendar_accounts',
@@ -16,8 +16,8 @@ exports.QuickAddFeatureSchema = zod_1.z.object({
16
16
  exports.UserSettingsSchema = zod_1.z.looseObject({
17
17
  completedSoundDesktop: zod_1.z.boolean(),
18
18
  completedSoundMobile: zod_1.z.boolean(),
19
- debugLogSendingEnabledUntil: zod_1.z.string().nullable(),
20
- legacyPricing: zod_1.z.boolean(),
19
+ debugLogSendingEnabledUntil: zod_1.z.string().nullish(),
20
+ legacyPricing: zod_1.z.union([zod_1.z.boolean(), zod_1.z.literal(0), zod_1.z.literal(1)]).transform(Boolean),
21
21
  navigation: zod_1.z
22
22
  .object({
23
23
  countsShown: zod_1.z.boolean(),
@@ -53,7 +53,7 @@ exports.SyncUserSchema = zod_1.z.looseObject({
53
53
  businessAccountId: zod_1.z.string().nullable(),
54
54
  dailyGoal: zod_1.z.number().int(),
55
55
  dateFormat: user_preferences_1.DateFormatSchema,
56
- dateistLang: zod_1.z.string().nullable(),
56
+ dateistLang: zod_1.z.string().nullish(),
57
57
  daysOff: zod_1.z.array(zod_1.z.number().int()),
58
58
  featureIdentifier: zod_1.z.string(),
59
59
  features: exports.FeaturesSchema,
@@ -72,8 +72,8 @@ exports.SyncUserSchema = zod_1.z.looseObject({
72
72
  karmaTrend: zod_1.z.string(),
73
73
  lang: zod_1.z.string(),
74
74
  mfaEnabled: zod_1.z.boolean().optional(),
75
- mobileHost: zod_1.z.string().nullable(),
76
- mobileNumber: zod_1.z.string().nullable(),
75
+ mobileHost: zod_1.z.string().nullish(),
76
+ mobileNumber: zod_1.z.string().nullish(),
77
77
  nextWeek: user_preferences_1.DayOfWeekSchema,
78
78
  onboardingLevel: zod_1.z.string().nullable().optional(),
79
79
  onboardingRole: zod_1.z.string().nullable().optional(),
@@ -100,7 +100,7 @@ exports.SyncUserSchema = zod_1.z.looseObject({
100
100
  startPage: zod_1.z.string(),
101
101
  themeId: zod_1.z.string(),
102
102
  timeFormat: user_preferences_1.TimeFormatSchema,
103
- token: zod_1.z.string(),
103
+ token: zod_1.z.string().optional(),
104
104
  tzInfo: exports.TzInfoSchema,
105
105
  uniquePrefix: zod_1.z.number().int(),
106
106
  verificationStatus: zod_1.z.string(),
@@ -2,11 +2,12 @@
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("../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");
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");
10
11
  const resources_1 = require("./resources");
11
12
  exports.SyncErrorSchema = zod_1.z.object({
12
13
  error: zod_1.z.string(),
@@ -20,10 +21,10 @@ exports.SyncResponseSchema = zod_1.z.looseObject({
20
21
  fullSync: zod_1.z.boolean().optional(),
21
22
  syncStatus: zod_1.z.record(zod_1.z.string(), zod_1.z.union([zod_1.z.literal('ok'), exports.SyncErrorSchema])).optional(),
22
23
  tempIdMapping: zod_1.z.record(zod_1.z.string(), zod_1.z.string()).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(),
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(),
27
28
  notes: zod_1.z.array(resources_1.NoteSchema).optional(),
28
29
  projectNotes: zod_1.z.array(resources_1.NoteSchema).optional(),
29
30
  filters: zod_1.z.array(resources_1.FilterSchema).optional(),
@@ -40,12 +41,13 @@ exports.SyncResponseSchema = zod_1.z.looseObject({
40
41
  completedInfo: zod_1.z.array(resources_1.CompletedInfoSchema).optional(),
41
42
  stats: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
42
43
  workspaces: zod_1.z.array(resources_1.SyncWorkspaceSchema).optional(),
43
- workspaceUsers: zod_1.z.array(types_5.WorkspaceUserSchema).optional(),
44
+ workspaceUsers: zod_1.z.array(types_6.WorkspaceUserSchema).optional(),
44
45
  workspaceFilters: zod_1.z.array(resources_1.WorkspaceFilterSchema).optional(),
45
46
  viewOptions: zod_1.z.array(resources_1.ViewOptionsSchema).optional(),
46
47
  projectViewOptionsDefaults: zod_1.z.array(resources_1.ProjectViewOptionsDefaultsSchema).optional(),
47
48
  roleActions: zod_1.z.array(zod_1.z.record(zod_1.z.string(), zod_1.z.unknown())).optional(),
48
49
  folders: zod_1.z.array(resources_1.FolderSchema).optional(),
50
+ goals: zod_1.z.array(types_1.GoalSchema).optional(),
49
51
  workspaceGoals: zod_1.z.array(resources_1.WorkspaceGoalSchema).optional(),
50
52
  dayOrders: zod_1.z.record(zod_1.z.string(), zod_1.z.number()).optional(),
51
53
  calendars: zod_1.z.array(resources_1.CalendarSchema).optional(),