@doist/todoist-sdk 10.2.0-next.3 → 10.2.0-next.4

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.
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GoalsClient = void 0;
4
- const zod_1 = require("zod");
5
4
  const endpoints_1 = require("../consts/endpoints");
6
5
  const http_client_1 = require("../transport/http-client");
7
6
  const request_helpers_1 = require("../utils/request-helpers");
@@ -43,7 +42,7 @@ class GoalsClient extends base_client_1.BaseClient {
43
42
  };
44
43
  }
45
44
  async getGoal(id) {
46
- zod_1.z.string().parse(id);
45
+ validators_1.IdSchema.parse(id);
47
46
  const response = await (0, http_client_1.request)({
48
47
  httpMethod: 'GET',
49
48
  baseUri: this.syncApiBase,
@@ -66,7 +65,7 @@ class GoalsClient extends base_client_1.BaseClient {
66
65
  return (0, validators_1.validateGoal)(response.data);
67
66
  }
68
67
  async updateGoal(id, args, requestId) {
69
- zod_1.z.string().parse(id);
68
+ validators_1.IdSchema.parse(id);
70
69
  const response = await (0, http_client_1.request)({
71
70
  httpMethod: 'POST',
72
71
  baseUri: this.syncApiBase,
@@ -79,7 +78,7 @@ class GoalsClient extends base_client_1.BaseClient {
79
78
  return (0, validators_1.validateGoal)(response.data);
80
79
  }
81
80
  async deleteGoal(id, requestId) {
82
- zod_1.z.string().parse(id);
81
+ validators_1.IdSchema.parse(id);
83
82
  const response = await (0, http_client_1.request)({
84
83
  httpMethod: 'DELETE',
85
84
  baseUri: this.syncApiBase,
@@ -91,7 +90,7 @@ class GoalsClient extends base_client_1.BaseClient {
91
90
  return (0, http_client_1.isSuccess)(response);
92
91
  }
93
92
  async completeGoal(id, requestId) {
94
- zod_1.z.string().parse(id);
93
+ validators_1.IdSchema.parse(id);
95
94
  const response = await (0, http_client_1.request)({
96
95
  httpMethod: 'POST',
97
96
  baseUri: this.syncApiBase,
@@ -103,7 +102,7 @@ class GoalsClient extends base_client_1.BaseClient {
103
102
  return (0, validators_1.validateGoal)(response.data);
104
103
  }
105
104
  async uncompleteGoal(id, requestId) {
106
- zod_1.z.string().parse(id);
105
+ validators_1.IdSchema.parse(id);
107
106
  const response = await (0, http_client_1.request)({
108
107
  httpMethod: 'POST',
109
108
  baseUri: this.syncApiBase,
@@ -115,8 +114,8 @@ class GoalsClient extends base_client_1.BaseClient {
115
114
  return (0, validators_1.validateGoal)(response.data);
116
115
  }
117
116
  async linkTaskToGoal({ goalId, taskId }, requestId) {
118
- zod_1.z.string().parse(goalId);
119
- zod_1.z.string().parse(taskId);
117
+ validators_1.IdSchema.parse(goalId);
118
+ validators_1.IdSchema.parse(taskId);
120
119
  const response = await (0, http_client_1.request)({
121
120
  httpMethod: 'POST',
122
121
  baseUri: this.syncApiBase,
@@ -129,8 +128,8 @@ class GoalsClient extends base_client_1.BaseClient {
129
128
  return (0, validators_1.validateGoal)(response.data);
130
129
  }
131
130
  async unlinkTaskFromGoal({ goalId, taskId }, requestId) {
132
- zod_1.z.string().parse(goalId);
133
- zod_1.z.string().parse(taskId);
131
+ validators_1.IdSchema.parse(goalId);
132
+ validators_1.IdSchema.parse(taskId);
134
133
  const response = await (0, http_client_1.request)({
135
134
  httpMethod: 'DELETE',
136
135
  baseUri: this.syncApiBase,
@@ -945,33 +945,101 @@ class TodoistApi {
945
945
  return this.folderClient.deleteFolder(id, requestId);
946
946
  }
947
947
  // ── Goals ──
948
+ /**
949
+ * Retrieves a paginated list of goals.
950
+ *
951
+ * @param args - Optional filters including owner type, workspace ID, cursor, and limit.
952
+ * @returns A promise that resolves to a paginated list of goals.
953
+ */
948
954
  async getGoals(args) {
949
955
  return this.goalsClient.getGoals(args);
950
956
  }
957
+ /**
958
+ * Searches for goals matching a query.
959
+ *
960
+ * @param args - Search parameters including query string and optional owner type.
961
+ * @returns A promise that resolves to a paginated list of matching goals.
962
+ */
951
963
  async searchGoals(args) {
952
964
  return this.goalsClient.searchGoals(args);
953
965
  }
966
+ /**
967
+ * Retrieves a single goal by its ID.
968
+ *
969
+ * @param id - The unique identifier of the goal.
970
+ * @returns A promise that resolves to the goal.
971
+ */
954
972
  async getGoal(id) {
955
973
  return this.goalsClient.getGoal(id);
956
974
  }
975
+ /**
976
+ * Creates a new goal.
977
+ *
978
+ * @param args - Goal attributes including name and optional workspace, description, deadline, and responsible user.
979
+ * @param requestId - Optional custom identifier for the request.
980
+ * @returns A promise that resolves to the created goal.
981
+ */
957
982
  async addGoal(args, requestId) {
958
983
  return this.goalsClient.addGoal(args, requestId);
959
984
  }
985
+ /**
986
+ * Updates an existing goal.
987
+ *
988
+ * @param id - The unique identifier of the goal to update.
989
+ * @param args - Attributes to update on the goal.
990
+ * @param requestId - Optional custom identifier for the request.
991
+ * @returns A promise that resolves to the updated goal.
992
+ */
960
993
  async updateGoal(id, args, requestId) {
961
994
  return this.goalsClient.updateGoal(id, args, requestId);
962
995
  }
996
+ /**
997
+ * Deletes a goal by its ID.
998
+ *
999
+ * @param id - The unique identifier of the goal to delete.
1000
+ * @param requestId - Optional custom identifier for the request.
1001
+ * @returns A promise that resolves to `true` if successful.
1002
+ */
963
1003
  async deleteGoal(id, requestId) {
964
1004
  return this.goalsClient.deleteGoal(id, requestId);
965
1005
  }
1006
+ /**
1007
+ * Marks a goal as complete.
1008
+ *
1009
+ * @param id - The unique identifier of the goal to complete.
1010
+ * @param requestId - Optional custom identifier for the request.
1011
+ * @returns A promise that resolves to the updated goal.
1012
+ */
966
1013
  async completeGoal(id, requestId) {
967
1014
  return this.goalsClient.completeGoal(id, requestId);
968
1015
  }
1016
+ /**
1017
+ * Marks a previously completed goal as incomplete.
1018
+ *
1019
+ * @param id - The unique identifier of the goal to uncomplete.
1020
+ * @param requestId - Optional custom identifier for the request.
1021
+ * @returns A promise that resolves to the updated goal.
1022
+ */
969
1023
  async uncompleteGoal(id, requestId) {
970
1024
  return this.goalsClient.uncompleteGoal(id, requestId);
971
1025
  }
1026
+ /**
1027
+ * Links a task to a goal so it contributes to goal progress.
1028
+ *
1029
+ * @param args - The goal ID and task ID to link.
1030
+ * @param requestId - Optional custom identifier for the request.
1031
+ * @returns A promise that resolves to the updated goal.
1032
+ */
972
1033
  async linkTaskToGoal(args, requestId) {
973
1034
  return this.goalsClient.linkTaskToGoal(args, requestId);
974
1035
  }
1036
+ /**
1037
+ * Unlinks a previously linked task from a goal.
1038
+ *
1039
+ * @param args - The goal ID and task ID to unlink.
1040
+ * @param requestId - Optional custom identifier for the request.
1041
+ * @returns A promise that resolves to `true` if successful.
1042
+ */
975
1043
  async unlinkTaskFromGoal(args, requestId) {
976
1044
  return this.goalsClient.unlinkTaskFromGoal(args, requestId);
977
1045
  }
@@ -1,8 +1,7 @@
1
- import { z } from 'zod';
2
1
  import { ENDPOINT_REST_GOALS, ENDPOINT_REST_GOALS_SEARCH, GOAL_COMPLETE, GOAL_TASKS, GOAL_UNCOMPLETE, } from '../consts/endpoints.js';
3
2
  import { isSuccess, request } from '../transport/http-client.js';
4
3
  import { generatePath } from '../utils/request-helpers.js';
5
- import { validateGoal, validateGoalArray } from '../utils/validators.js';
4
+ import { IdSchema, validateGoal, validateGoalArray } from '../utils/validators.js';
6
5
  import { BaseClient } from './base-client.js';
7
6
  /**
8
7
  * Internal sub-client handling all goal-domain endpoints.
@@ -40,7 +39,7 @@ export class GoalsClient extends BaseClient {
40
39
  };
41
40
  }
42
41
  async getGoal(id) {
43
- z.string().parse(id);
42
+ IdSchema.parse(id);
44
43
  const response = await request({
45
44
  httpMethod: 'GET',
46
45
  baseUri: this.syncApiBase,
@@ -63,7 +62,7 @@ export class GoalsClient extends BaseClient {
63
62
  return validateGoal(response.data);
64
63
  }
65
64
  async updateGoal(id, args, requestId) {
66
- z.string().parse(id);
65
+ IdSchema.parse(id);
67
66
  const response = await request({
68
67
  httpMethod: 'POST',
69
68
  baseUri: this.syncApiBase,
@@ -76,7 +75,7 @@ export class GoalsClient extends BaseClient {
76
75
  return validateGoal(response.data);
77
76
  }
78
77
  async deleteGoal(id, requestId) {
79
- z.string().parse(id);
78
+ IdSchema.parse(id);
80
79
  const response = await request({
81
80
  httpMethod: 'DELETE',
82
81
  baseUri: this.syncApiBase,
@@ -88,7 +87,7 @@ export class GoalsClient extends BaseClient {
88
87
  return isSuccess(response);
89
88
  }
90
89
  async completeGoal(id, requestId) {
91
- z.string().parse(id);
90
+ IdSchema.parse(id);
92
91
  const response = await request({
93
92
  httpMethod: 'POST',
94
93
  baseUri: this.syncApiBase,
@@ -100,7 +99,7 @@ export class GoalsClient extends BaseClient {
100
99
  return validateGoal(response.data);
101
100
  }
102
101
  async uncompleteGoal(id, requestId) {
103
- z.string().parse(id);
102
+ IdSchema.parse(id);
104
103
  const response = await request({
105
104
  httpMethod: 'POST',
106
105
  baseUri: this.syncApiBase,
@@ -112,8 +111,8 @@ export class GoalsClient extends BaseClient {
112
111
  return validateGoal(response.data);
113
112
  }
114
113
  async linkTaskToGoal({ goalId, taskId }, requestId) {
115
- z.string().parse(goalId);
116
- z.string().parse(taskId);
114
+ IdSchema.parse(goalId);
115
+ IdSchema.parse(taskId);
117
116
  const response = await request({
118
117
  httpMethod: 'POST',
119
118
  baseUri: this.syncApiBase,
@@ -126,8 +125,8 @@ export class GoalsClient extends BaseClient {
126
125
  return validateGoal(response.data);
127
126
  }
128
127
  async unlinkTaskFromGoal({ goalId, taskId }, requestId) {
129
- z.string().parse(goalId);
130
- z.string().parse(taskId);
128
+ IdSchema.parse(goalId);
129
+ IdSchema.parse(taskId);
131
130
  const response = await request({
132
131
  httpMethod: 'DELETE',
133
132
  baseUri: this.syncApiBase,
@@ -942,33 +942,101 @@ export class TodoistApi {
942
942
  return this.folderClient.deleteFolder(id, requestId);
943
943
  }
944
944
  // ── Goals ──
945
+ /**
946
+ * Retrieves a paginated list of goals.
947
+ *
948
+ * @param args - Optional filters including owner type, workspace ID, cursor, and limit.
949
+ * @returns A promise that resolves to a paginated list of goals.
950
+ */
945
951
  async getGoals(args) {
946
952
  return this.goalsClient.getGoals(args);
947
953
  }
954
+ /**
955
+ * Searches for goals matching a query.
956
+ *
957
+ * @param args - Search parameters including query string and optional owner type.
958
+ * @returns A promise that resolves to a paginated list of matching goals.
959
+ */
948
960
  async searchGoals(args) {
949
961
  return this.goalsClient.searchGoals(args);
950
962
  }
963
+ /**
964
+ * Retrieves a single goal by its ID.
965
+ *
966
+ * @param id - The unique identifier of the goal.
967
+ * @returns A promise that resolves to the goal.
968
+ */
951
969
  async getGoal(id) {
952
970
  return this.goalsClient.getGoal(id);
953
971
  }
972
+ /**
973
+ * Creates a new goal.
974
+ *
975
+ * @param args - Goal attributes including name and optional workspace, description, deadline, and responsible user.
976
+ * @param requestId - Optional custom identifier for the request.
977
+ * @returns A promise that resolves to the created goal.
978
+ */
954
979
  async addGoal(args, requestId) {
955
980
  return this.goalsClient.addGoal(args, requestId);
956
981
  }
982
+ /**
983
+ * Updates an existing goal.
984
+ *
985
+ * @param id - The unique identifier of the goal to update.
986
+ * @param args - Attributes to update on the goal.
987
+ * @param requestId - Optional custom identifier for the request.
988
+ * @returns A promise that resolves to the updated goal.
989
+ */
957
990
  async updateGoal(id, args, requestId) {
958
991
  return this.goalsClient.updateGoal(id, args, requestId);
959
992
  }
993
+ /**
994
+ * Deletes a goal by its ID.
995
+ *
996
+ * @param id - The unique identifier of the goal to delete.
997
+ * @param requestId - Optional custom identifier for the request.
998
+ * @returns A promise that resolves to `true` if successful.
999
+ */
960
1000
  async deleteGoal(id, requestId) {
961
1001
  return this.goalsClient.deleteGoal(id, requestId);
962
1002
  }
1003
+ /**
1004
+ * Marks a goal as complete.
1005
+ *
1006
+ * @param id - The unique identifier of the goal to complete.
1007
+ * @param requestId - Optional custom identifier for the request.
1008
+ * @returns A promise that resolves to the updated goal.
1009
+ */
963
1010
  async completeGoal(id, requestId) {
964
1011
  return this.goalsClient.completeGoal(id, requestId);
965
1012
  }
1013
+ /**
1014
+ * Marks a previously completed goal as incomplete.
1015
+ *
1016
+ * @param id - The unique identifier of the goal to uncomplete.
1017
+ * @param requestId - Optional custom identifier for the request.
1018
+ * @returns A promise that resolves to the updated goal.
1019
+ */
966
1020
  async uncompleteGoal(id, requestId) {
967
1021
  return this.goalsClient.uncompleteGoal(id, requestId);
968
1022
  }
1023
+ /**
1024
+ * Links a task to a goal so it contributes to goal progress.
1025
+ *
1026
+ * @param args - The goal ID and task ID to link.
1027
+ * @param requestId - Optional custom identifier for the request.
1028
+ * @returns A promise that resolves to the updated goal.
1029
+ */
969
1030
  async linkTaskToGoal(args, requestId) {
970
1031
  return this.goalsClient.linkTaskToGoal(args, requestId);
971
1032
  }
1033
+ /**
1034
+ * Unlinks a previously linked task from a goal.
1035
+ *
1036
+ * @param args - The goal ID and task ID to unlink.
1037
+ * @param requestId - Optional custom identifier for the request.
1038
+ * @returns A promise that resolves to `true` if successful.
1039
+ */
972
1040
  async unlinkTaskFromGoal(args, requestId) {
973
1041
  return this.goalsClient.unlinkTaskFromGoal(args, requestId);
974
1042
  }
@@ -789,15 +789,83 @@ export declare class TodoistApi {
789
789
  * @returns A promise that resolves to `true` if successful.
790
790
  */
791
791
  deleteFolder(id: string, requestId?: string): Promise<boolean>;
792
+ /**
793
+ * Retrieves a paginated list of goals.
794
+ *
795
+ * @param args - Optional filters including owner type, workspace ID, cursor, and limit.
796
+ * @returns A promise that resolves to a paginated list of goals.
797
+ */
792
798
  getGoals(args?: GetGoalsArgs): Promise<GetGoalsResponse>;
799
+ /**
800
+ * Searches for goals matching a query.
801
+ *
802
+ * @param args - Search parameters including query string and optional owner type.
803
+ * @returns A promise that resolves to a paginated list of matching goals.
804
+ */
793
805
  searchGoals(args: SearchGoalsArgs): Promise<GetGoalsResponse>;
806
+ /**
807
+ * Retrieves a single goal by its ID.
808
+ *
809
+ * @param id - The unique identifier of the goal.
810
+ * @returns A promise that resolves to the goal.
811
+ */
794
812
  getGoal(id: string): Promise<Goal>;
813
+ /**
814
+ * Creates a new goal.
815
+ *
816
+ * @param args - Goal attributes including name and optional workspace, description, deadline, and responsible user.
817
+ * @param requestId - Optional custom identifier for the request.
818
+ * @returns A promise that resolves to the created goal.
819
+ */
795
820
  addGoal(args: AddGoalArgs, requestId?: string): Promise<Goal>;
821
+ /**
822
+ * Updates an existing goal.
823
+ *
824
+ * @param id - The unique identifier of the goal to update.
825
+ * @param args - Attributes to update on the goal.
826
+ * @param requestId - Optional custom identifier for the request.
827
+ * @returns A promise that resolves to the updated goal.
828
+ */
796
829
  updateGoal(id: string, args: UpdateGoalArgs, requestId?: string): Promise<Goal>;
830
+ /**
831
+ * Deletes a goal by its ID.
832
+ *
833
+ * @param id - The unique identifier of the goal to delete.
834
+ * @param requestId - Optional custom identifier for the request.
835
+ * @returns A promise that resolves to `true` if successful.
836
+ */
797
837
  deleteGoal(id: string, requestId?: string): Promise<boolean>;
838
+ /**
839
+ * Marks a goal as complete.
840
+ *
841
+ * @param id - The unique identifier of the goal to complete.
842
+ * @param requestId - Optional custom identifier for the request.
843
+ * @returns A promise that resolves to the updated goal.
844
+ */
798
845
  completeGoal(id: string, requestId?: string): Promise<Goal>;
846
+ /**
847
+ * Marks a previously completed goal as incomplete.
848
+ *
849
+ * @param id - The unique identifier of the goal to uncomplete.
850
+ * @param requestId - Optional custom identifier for the request.
851
+ * @returns A promise that resolves to the updated goal.
852
+ */
799
853
  uncompleteGoal(id: string, requestId?: string): Promise<Goal>;
854
+ /**
855
+ * Links a task to a goal so it contributes to goal progress.
856
+ *
857
+ * @param args - The goal ID and task ID to link.
858
+ * @param requestId - Optional custom identifier for the request.
859
+ * @returns A promise that resolves to the updated goal.
860
+ */
800
861
  linkTaskToGoal(args: TaskLinkingArgs, requestId?: string): Promise<Goal>;
862
+ /**
863
+ * Unlinks a previously linked task from a goal.
864
+ *
865
+ * @param args - The goal ID and task ID to unlink.
866
+ * @param requestId - Optional custom identifier for the request.
867
+ * @returns A promise that resolves to `true` if successful.
868
+ */
801
869
  unlinkTaskFromGoal(args: TaskLinkingArgs, requestId?: string): Promise<boolean>;
802
870
  /**
803
871
  * Retrieves a list of available backups.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doist/todoist-sdk",
3
- "version": "10.2.0-next.3",
3
+ "version": "10.2.0-next.4",
4
4
  "description": "The official TypeScript SDK for the Todoist REST API.",
5
5
  "author": "Doist developers",
6
6
  "repository": "https://github.com/Doist/todoist-sdk-typescript",
@@ -41,11 +41,14 @@
41
41
  "build:fix-dts": "node scripts/fix-dts-imports.cjs",
42
42
  "build:post": "echo '{\"type\":\"commonjs\"}' > dist/cjs/package.json",
43
43
  "build": "npm-run-all clean build:cjs build:esm build:fix-esm build:fix-dts build:post",
44
- "attw": "npx @arethetypeswrong/cli --pack --ignore-rules fallback-condition false-esm",
44
+ "attw": "attw --pack --ignore-rules fallback-condition false-esm",
45
45
  "integrity-checks": "npm-run-all clean check test build attw",
46
46
  "prepublishOnly": "npm run integrity-checks",
47
47
  "prepare": "npm run build"
48
48
  },
49
+ "overrides": {
50
+ "fflate": "0.8.2"
51
+ },
49
52
  "dependencies": {
50
53
  "camelcase": "6.3.0",
51
54
  "emoji-regex": "10.6.0",
@@ -56,6 +59,7 @@
56
59
  "zod": "4.3.6"
57
60
  },
58
61
  "devDependencies": {
62
+ "@arethetypeswrong/cli": "0.18.2",
59
63
  "@semantic-release/changelog": "6.0.3",
60
64
  "@semantic-release/git": "10.0.1",
61
65
  "conventional-changelog-conventionalcommits": "9.3.1",