@doist/todoist-sdk 9.2.0 → 9.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 (45) hide show
  1. package/dist/cjs/clients/app-client.js +17 -17
  2. package/dist/cjs/clients/comment-client.js +3 -4
  3. package/dist/cjs/clients/folder-client.js +3 -4
  4. package/dist/cjs/clients/insights-client.js +6 -7
  5. package/dist/cjs/clients/label-client.js +3 -4
  6. package/dist/cjs/clients/project-client.js +8 -9
  7. package/dist/cjs/clients/section-client.js +5 -6
  8. package/dist/cjs/clients/task-client.js +6 -7
  9. package/dist/cjs/clients/ui-extension-client.js +4 -5
  10. package/dist/cjs/clients/workspace-client.js +3 -4
  11. package/dist/cjs/types/index.js +1 -0
  12. package/dist/cjs/types/webhooks/envelope.js +26 -0
  13. package/dist/cjs/types/webhooks/index.js +19 -0
  14. package/dist/cjs/types/webhooks/tasks.js +68 -0
  15. package/dist/cjs/types/webhooks/types.js +34 -0
  16. package/dist/cjs/utils/index.js +4 -1
  17. package/dist/cjs/utils/validators.js +7 -2
  18. package/dist/cjs/utils/webhook-parser.js +60 -0
  19. package/dist/esm/clients/app-client.js +18 -18
  20. package/dist/esm/clients/comment-client.js +4 -5
  21. package/dist/esm/clients/folder-client.js +4 -5
  22. package/dist/esm/clients/insights-client.js +7 -8
  23. package/dist/esm/clients/label-client.js +4 -5
  24. package/dist/esm/clients/project-client.js +9 -10
  25. package/dist/esm/clients/section-client.js +6 -7
  26. package/dist/esm/clients/task-client.js +7 -8
  27. package/dist/esm/clients/ui-extension-client.js +5 -6
  28. package/dist/esm/clients/workspace-client.js +4 -5
  29. package/dist/esm/types/index.js +1 -0
  30. package/dist/esm/types/webhooks/envelope.js +23 -0
  31. package/dist/esm/types/webhooks/index.js +3 -0
  32. package/dist/esm/types/webhooks/tasks.js +65 -0
  33. package/dist/esm/types/webhooks/types.js +31 -0
  34. package/dist/esm/utils/index.js +1 -0
  35. package/dist/esm/utils/validators.js +5 -0
  36. package/dist/esm/utils/webhook-parser.js +56 -0
  37. package/dist/types/types/index.d.ts +1 -0
  38. package/dist/types/types/webhooks/envelope.d.ts +34 -0
  39. package/dist/types/types/webhooks/index.d.ts +3 -0
  40. package/dist/types/types/webhooks/tasks.d.ts +981 -0
  41. package/dist/types/types/webhooks/types.d.ts +893 -0
  42. package/dist/types/utils/index.d.ts +2 -0
  43. package/dist/types/utils/validators.d.ts +2 -0
  44. package/dist/types/utils/webhook-parser.d.ts +48 -0
  45. package/package.json +1 -1
@@ -41,7 +41,7 @@ class AppClient extends base_client_1.BaseClient {
41
41
  return (0, validators_1.validateAppArray)(response.data);
42
42
  }
43
43
  async getApp(appId, requestId) {
44
- zod_1.z.string().min(1).parse(appId);
44
+ validators_1.IdSchema.parse(appId);
45
45
  const response = await (0, http_client_1.request)({
46
46
  httpMethod: 'GET',
47
47
  baseUri: this.apiRootBase,
@@ -65,7 +65,7 @@ class AppClient extends base_client_1.BaseClient {
65
65
  return (0, validators_1.validateApp)(response.data);
66
66
  }
67
67
  async updateApp(appId, args, requestId) {
68
- zod_1.z.string().min(1).parse(appId);
68
+ validators_1.IdSchema.parse(appId);
69
69
  const { appTokenScopes } = args, rest = __rest(args, ["appTokenScopes"]);
70
70
  const payload = Object.assign({}, rest);
71
71
  if (appTokenScopes !== undefined) {
@@ -83,7 +83,7 @@ class AppClient extends base_client_1.BaseClient {
83
83
  return (0, validators_1.validateAppWithUserCount)(response.data);
84
84
  }
85
85
  async deleteApp(appId, requestId) {
86
- zod_1.z.string().min(1).parse(appId);
86
+ validators_1.IdSchema.parse(appId);
87
87
  const response = await (0, http_client_1.request)({
88
88
  httpMethod: 'DELETE',
89
89
  baseUri: this.apiRootBase,
@@ -95,7 +95,7 @@ class AppClient extends base_client_1.BaseClient {
95
95
  return (0, http_client_1.isSuccess)(response);
96
96
  }
97
97
  async getAppSecrets(appId, requestId) {
98
- zod_1.z.string().min(1).parse(appId);
98
+ validators_1.IdSchema.parse(appId);
99
99
  const response = await (0, http_client_1.request)({
100
100
  httpMethod: 'GET',
101
101
  baseUri: this.apiRootBase,
@@ -107,7 +107,7 @@ class AppClient extends base_client_1.BaseClient {
107
107
  return (0, validators_1.validateAppSecrets)(response.data);
108
108
  }
109
109
  async resetAppClientSecret(appId, requestId) {
110
- zod_1.z.string().min(1).parse(appId);
110
+ validators_1.IdSchema.parse(appId);
111
111
  const response = await (0, http_client_1.request)({
112
112
  httpMethod: 'DELETE',
113
113
  baseUri: this.apiRootBase,
@@ -119,7 +119,7 @@ class AppClient extends base_client_1.BaseClient {
119
119
  return (0, validators_1.validateAppWithUserCount)(response.data);
120
120
  }
121
121
  async revokeAppTokens(appId, requestId) {
122
- zod_1.z.string().min(1).parse(appId);
122
+ validators_1.IdSchema.parse(appId);
123
123
  const response = await (0, http_client_1.request)({
124
124
  httpMethod: 'DELETE',
125
125
  baseUri: this.apiRootBase,
@@ -131,7 +131,7 @@ class AppClient extends base_client_1.BaseClient {
131
131
  return (0, validators_1.validateAppWithUserCount)(response.data);
132
132
  }
133
133
  async uploadAppIcon({ appId, file, fileName = '', size = 'medium' }, requestId) {
134
- zod_1.z.string().min(1).parse(appId);
134
+ validators_1.IdSchema.parse(appId);
135
135
  if (Buffer.isBuffer(file) && file.length === 0) {
136
136
  throw new Error('Cannot upload empty image file');
137
137
  }
@@ -148,7 +148,7 @@ class AppClient extends base_client_1.BaseClient {
148
148
  return (0, validators_1.validateAppWithUserCount)((0, case_conversion_1.camelCaseKeys)(data));
149
149
  }
150
150
  async getAppTestToken(appId, requestId) {
151
- zod_1.z.string().min(1).parse(appId);
151
+ validators_1.IdSchema.parse(appId);
152
152
  const response = await (0, http_client_1.request)({
153
153
  httpMethod: 'GET',
154
154
  baseUri: this.apiRootBase,
@@ -160,7 +160,7 @@ class AppClient extends base_client_1.BaseClient {
160
160
  return (0, validators_1.validateAppTestToken)(response.data);
161
161
  }
162
162
  async createAppTestToken(appId, requestId) {
163
- zod_1.z.string().min(1).parse(appId);
163
+ validators_1.IdSchema.parse(appId);
164
164
  const response = await (0, http_client_1.request)({
165
165
  httpMethod: 'PUT',
166
166
  baseUri: this.apiRootBase,
@@ -172,7 +172,7 @@ class AppClient extends base_client_1.BaseClient {
172
172
  return (0, validators_1.validateAppTestToken)(response.data);
173
173
  }
174
174
  async getAppDistributionToken(appId, requestId) {
175
- zod_1.z.string().min(1).parse(appId);
175
+ validators_1.IdSchema.parse(appId);
176
176
  const response = await (0, http_client_1.request)({
177
177
  httpMethod: 'GET',
178
178
  baseUri: this.apiRootBase,
@@ -184,7 +184,7 @@ class AppClient extends base_client_1.BaseClient {
184
184
  return (0, validators_1.validateAppDistributionToken)(response.data);
185
185
  }
186
186
  async getAppVerificationToken(appId, requestId) {
187
- zod_1.z.string().min(1).parse(appId);
187
+ validators_1.IdSchema.parse(appId);
188
188
  const response = await (0, http_client_1.request)({
189
189
  httpMethod: 'GET',
190
190
  baseUri: this.apiRootBase,
@@ -196,7 +196,7 @@ class AppClient extends base_client_1.BaseClient {
196
196
  return (0, validators_1.validateAppVerificationToken)(response.data);
197
197
  }
198
198
  async resetAppVerificationToken(appId, requestId) {
199
- zod_1.z.string().min(1).parse(appId);
199
+ validators_1.IdSchema.parse(appId);
200
200
  const response = await (0, http_client_1.request)({
201
201
  httpMethod: 'DELETE',
202
202
  baseUri: this.apiRootBase,
@@ -221,7 +221,7 @@ class AppClient extends base_client_1.BaseClient {
221
221
  }
222
222
  // --- App webhooks ---
223
223
  async getAppWebhook(appId, requestId) {
224
- zod_1.z.string().min(1).parse(appId);
224
+ validators_1.IdSchema.parse(appId);
225
225
  const response = await (0, http_client_1.request)({
226
226
  httpMethod: 'GET',
227
227
  baseUri: this.apiRootBase,
@@ -246,7 +246,7 @@ class AppClient extends base_client_1.BaseClient {
246
246
  return (0, validators_1.validateAppWebhook)(response.data);
247
247
  }
248
248
  async deleteAppWebhook(appId, requestId) {
249
- zod_1.z.string().min(1).parse(appId);
249
+ validators_1.IdSchema.parse(appId);
250
250
  const response = await (0, http_client_1.request)({
251
251
  httpMethod: 'DELETE',
252
252
  baseUri: this.apiRootBase,
@@ -282,7 +282,7 @@ class AppClient extends base_client_1.BaseClient {
282
282
  return (0, validators_1.validateAppInstallation)(response.data);
283
283
  }
284
284
  async getAppInstallation(installationId, requestId) {
285
- zod_1.z.string().min(1).parse(installationId);
285
+ validators_1.IdSchema.parse(installationId);
286
286
  const response = await (0, http_client_1.request)({
287
287
  httpMethod: 'GET',
288
288
  baseUri: this.apiRootBase,
@@ -294,7 +294,7 @@ class AppClient extends base_client_1.BaseClient {
294
294
  return (0, validators_1.validateAppInstallation)(response.data);
295
295
  }
296
296
  async updateAppInstallation(installationId, args, requestId) {
297
- zod_1.z.string().min(1).parse(installationId);
297
+ validators_1.IdSchema.parse(installationId);
298
298
  const response = await (0, http_client_1.request)({
299
299
  httpMethod: 'POST',
300
300
  baseUri: this.apiRootBase,
@@ -307,7 +307,7 @@ class AppClient extends base_client_1.BaseClient {
307
307
  return (0, validators_1.validateAppInstallation)(response.data);
308
308
  }
309
309
  async uninstallApp(installationId, requestId) {
310
- zod_1.z.string().min(1).parse(installationId);
310
+ validators_1.IdSchema.parse(installationId);
311
311
  const response = await (0, http_client_1.request)({
312
312
  httpMethod: 'DELETE',
313
313
  baseUri: this.apiRootBase,
@@ -12,7 +12,6 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.CommentClient = void 0;
15
- const zod_1 = require("zod");
16
15
  const endpoints_1 = require("../consts/endpoints");
17
16
  const http_client_1 = require("../transport/http-client");
18
17
  const request_helpers_1 = require("../utils/request-helpers");
@@ -40,7 +39,7 @@ class CommentClient extends base_client_1.BaseClient {
40
39
  };
41
40
  }
42
41
  async getComment(id) {
43
- zod_1.z.string().min(1).parse(id);
42
+ validators_1.IdSchema.parse(id);
44
43
  const response = await (0, http_client_1.request)({
45
44
  httpMethod: 'GET',
46
45
  baseUri: this.syncApiBase,
@@ -64,7 +63,7 @@ class CommentClient extends base_client_1.BaseClient {
64
63
  return (0, validators_1.validateComment)(response.data);
65
64
  }
66
65
  async updateComment(id, args, requestId) {
67
- zod_1.z.string().min(1).parse(id);
66
+ validators_1.IdSchema.parse(id);
68
67
  const response = await (0, http_client_1.request)({
69
68
  httpMethod: 'POST',
70
69
  baseUri: this.syncApiBase,
@@ -77,7 +76,7 @@ class CommentClient extends base_client_1.BaseClient {
77
76
  return (0, validators_1.validateComment)(response.data);
78
77
  }
79
78
  async deleteComment(id, requestId) {
80
- zod_1.z.string().min(1).parse(id);
79
+ validators_1.IdSchema.parse(id);
81
80
  const response = await (0, http_client_1.request)({
82
81
  httpMethod: 'DELETE',
83
82
  baseUri: this.syncApiBase,
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FolderClient = 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");
@@ -29,7 +28,7 @@ class FolderClient extends base_client_1.BaseClient {
29
28
  };
30
29
  }
31
30
  async getFolder(id) {
32
- zod_1.z.string().min(1).parse(id);
31
+ validators_1.IdSchema.parse(id);
33
32
  const response = await (0, http_client_1.request)({
34
33
  httpMethod: 'GET',
35
34
  baseUri: this.syncApiBase,
@@ -52,7 +51,7 @@ class FolderClient extends base_client_1.BaseClient {
52
51
  return (0, validators_1.validateFolder)(response.data);
53
52
  }
54
53
  async updateFolder(id, args, requestId) {
55
- zod_1.z.string().min(1).parse(id);
54
+ validators_1.IdSchema.parse(id);
56
55
  const response = await (0, http_client_1.request)({
57
56
  httpMethod: 'POST',
58
57
  baseUri: this.syncApiBase,
@@ -65,7 +64,7 @@ class FolderClient extends base_client_1.BaseClient {
65
64
  return (0, validators_1.validateFolder)(response.data);
66
65
  }
67
66
  async deleteFolder(id, requestId) {
68
- zod_1.z.string().min(1).parse(id);
67
+ validators_1.IdSchema.parse(id);
69
68
  const response = await (0, http_client_1.request)({
70
69
  httpMethod: 'DELETE',
71
70
  baseUri: this.syncApiBase,
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InsightsClient = 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 validators_1 = require("../utils/validators");
@@ -16,7 +15,7 @@ const base_client_1 = require("./base-client");
16
15
  */
17
16
  class InsightsClient extends base_client_1.BaseClient {
18
17
  async getProjectActivityStats(projectId, args = {}) {
19
- zod_1.z.string().min(1).parse(projectId);
18
+ validators_1.IdSchema.parse(projectId);
20
19
  const response = await (0, http_client_1.request)({
21
20
  httpMethod: 'GET',
22
21
  baseUri: this.syncApiBase,
@@ -28,7 +27,7 @@ class InsightsClient extends base_client_1.BaseClient {
28
27
  return (0, validators_1.validateProjectActivityStats)(response.data);
29
28
  }
30
29
  async getProjectHealth(projectId) {
31
- zod_1.z.string().min(1).parse(projectId);
30
+ validators_1.IdSchema.parse(projectId);
32
31
  const response = await (0, http_client_1.request)({
33
32
  httpMethod: 'GET',
34
33
  baseUri: this.syncApiBase,
@@ -39,7 +38,7 @@ class InsightsClient extends base_client_1.BaseClient {
39
38
  return (0, validators_1.validateProjectHealth)(response.data);
40
39
  }
41
40
  async getProjectHealthContext(projectId) {
42
- zod_1.z.string().min(1).parse(projectId);
41
+ validators_1.IdSchema.parse(projectId);
43
42
  const response = await (0, http_client_1.request)({
44
43
  httpMethod: 'GET',
45
44
  baseUri: this.syncApiBase,
@@ -50,7 +49,7 @@ class InsightsClient extends base_client_1.BaseClient {
50
49
  return (0, validators_1.validateProjectHealthContext)(response.data);
51
50
  }
52
51
  async getProjectProgress(projectId) {
53
- zod_1.z.string().min(1).parse(projectId);
52
+ validators_1.IdSchema.parse(projectId);
54
53
  const response = await (0, http_client_1.request)({
55
54
  httpMethod: 'GET',
56
55
  baseUri: this.syncApiBase,
@@ -61,7 +60,7 @@ class InsightsClient extends base_client_1.BaseClient {
61
60
  return (0, validators_1.validateProjectProgress)(response.data);
62
61
  }
63
62
  async getWorkspaceInsights(workspaceId, args = {}) {
64
- zod_1.z.string().min(1).parse(workspaceId);
63
+ validators_1.IdSchema.parse(workspaceId);
65
64
  const response = await (0, http_client_1.request)({
66
65
  httpMethod: 'GET',
67
66
  baseUri: this.syncApiBase,
@@ -73,7 +72,7 @@ class InsightsClient extends base_client_1.BaseClient {
73
72
  return (0, validators_1.validateWorkspaceInsights)(response.data);
74
73
  }
75
74
  async analyzeProjectHealth(projectId, requestId) {
76
- zod_1.z.string().min(1).parse(projectId);
75
+ validators_1.IdSchema.parse(projectId);
77
76
  const response = await (0, http_client_1.request)({
78
77
  httpMethod: 'POST',
79
78
  baseUri: this.syncApiBase,
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LabelClient = 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");
@@ -15,7 +14,7 @@ const base_client_1 = require("./base-client");
15
14
  */
16
15
  class LabelClient extends base_client_1.BaseClient {
17
16
  async getLabel(id) {
18
- zod_1.z.string().min(1).parse(id);
17
+ validators_1.IdSchema.parse(id);
19
18
  const response = await (0, http_client_1.request)({
20
19
  httpMethod: 'GET',
21
20
  baseUri: this.syncApiBase,
@@ -66,7 +65,7 @@ class LabelClient extends base_client_1.BaseClient {
66
65
  return (0, validators_1.validateLabel)(response.data);
67
66
  }
68
67
  async updateLabel(id, args, requestId) {
69
- zod_1.z.string().min(1).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 LabelClient extends base_client_1.BaseClient {
79
78
  return (0, validators_1.validateLabel)(response.data);
80
79
  }
81
80
  async deleteLabel(id, requestId) {
82
- zod_1.z.string().min(1).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,
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ProjectClient = 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");
@@ -15,7 +14,7 @@ const base_client_1 = require("./base-client");
15
14
  */
16
15
  class ProjectClient extends base_client_1.BaseClient {
17
16
  async getProject(id) {
18
- zod_1.z.string().min(1).parse(id);
17
+ validators_1.IdSchema.parse(id);
19
18
  const response = await (0, http_client_1.request)({
20
19
  httpMethod: 'GET',
21
20
  baseUri: this.syncApiBase,
@@ -80,7 +79,7 @@ class ProjectClient extends base_client_1.BaseClient {
80
79
  return (0, validators_1.validateProject)(response.data);
81
80
  }
82
81
  async updateProject(id, args, requestId) {
83
- zod_1.z.string().min(1).parse(id);
82
+ validators_1.IdSchema.parse(id);
84
83
  const response = await (0, http_client_1.request)({
85
84
  httpMethod: 'POST',
86
85
  baseUri: this.syncApiBase,
@@ -93,7 +92,7 @@ class ProjectClient extends base_client_1.BaseClient {
93
92
  return (0, validators_1.validateProject)(response.data);
94
93
  }
95
94
  async deleteProject(id, requestId) {
96
- zod_1.z.string().min(1).parse(id);
95
+ validators_1.IdSchema.parse(id);
97
96
  const response = await (0, http_client_1.request)({
98
97
  httpMethod: 'DELETE',
99
98
  baseUri: this.syncApiBase,
@@ -105,7 +104,7 @@ class ProjectClient extends base_client_1.BaseClient {
105
104
  return (0, http_client_1.isSuccess)(response);
106
105
  }
107
106
  async archiveProject(id, requestId) {
108
- zod_1.z.string().min(1).parse(id);
107
+ validators_1.IdSchema.parse(id);
109
108
  const response = await (0, http_client_1.request)({
110
109
  httpMethod: 'POST',
111
110
  baseUri: this.syncApiBase,
@@ -117,7 +116,7 @@ class ProjectClient extends base_client_1.BaseClient {
117
116
  return (0, validators_1.validateProject)(response.data);
118
117
  }
119
118
  async unarchiveProject(id, requestId) {
120
- zod_1.z.string().min(1).parse(id);
119
+ validators_1.IdSchema.parse(id);
121
120
  const response = await (0, http_client_1.request)({
122
121
  httpMethod: 'POST',
123
122
  baseUri: this.syncApiBase,
@@ -174,7 +173,7 @@ class ProjectClient extends base_client_1.BaseClient {
174
173
  return data;
175
174
  }
176
175
  async getFullProject(id, args = {}) {
177
- zod_1.z.string().min(1).parse(id);
176
+ validators_1.IdSchema.parse(id);
178
177
  const { data } = await (0, http_client_1.request)({
179
178
  httpMethod: 'GET',
180
179
  baseUri: this.syncApiBase,
@@ -193,7 +192,7 @@ class ProjectClient extends base_client_1.BaseClient {
193
192
  };
194
193
  }
195
194
  async joinProject(id, requestId) {
196
- zod_1.z.string().min(1).parse(id);
195
+ validators_1.IdSchema.parse(id);
197
196
  const { data } = await (0, http_client_1.request)({
198
197
  httpMethod: 'POST',
199
198
  baseUri: this.syncApiBase,
@@ -214,7 +213,7 @@ class ProjectClient extends base_client_1.BaseClient {
214
213
  };
215
214
  }
216
215
  async getProjectCollaborators(projectId, args = {}) {
217
- zod_1.z.string().min(1).parse(projectId);
216
+ validators_1.IdSchema.parse(projectId);
218
217
  const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
219
218
  httpMethod: 'GET',
220
219
  baseUri: this.syncApiBase,
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SectionClient = 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 SectionClient extends base_client_1.BaseClient {
43
42
  };
44
43
  }
45
44
  async getSection(id) {
46
- zod_1.z.string().min(1).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 SectionClient extends base_client_1.BaseClient {
66
65
  return (0, validators_1.validateSection)(response.data);
67
66
  }
68
67
  async updateSection(id, args, requestId) {
69
- zod_1.z.string().min(1).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 SectionClient extends base_client_1.BaseClient {
79
78
  return (0, validators_1.validateSection)(response.data);
80
79
  }
81
80
  async deleteSection(id, requestId) {
82
- zod_1.z.string().min(1).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 SectionClient extends base_client_1.BaseClient {
91
90
  return (0, http_client_1.isSuccess)(response);
92
91
  }
93
92
  async archiveSection(id, requestId) {
94
- zod_1.z.string().min(1).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 SectionClient extends base_client_1.BaseClient {
103
102
  return (0, validators_1.validateSection)(response.data);
104
103
  }
105
104
  async unarchiveSection(id, requestId) {
106
- zod_1.z.string().min(1).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,
@@ -13,7 +13,6 @@ var __rest = (this && this.__rest) || function (s, e) {
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.TaskClient = void 0;
15
15
  const uuid_1 = require("uuid");
16
- const zod_1 = require("zod");
17
16
  const endpoints_1 = require("../consts/endpoints");
18
17
  const http_client_1 = require("../transport/http-client");
19
18
  const sync_request_1 = require("../transport/sync-request");
@@ -31,7 +30,7 @@ const MAX_COMMAND_COUNT = 100;
31
30
  */
32
31
  class TaskClient extends base_client_1.BaseClient {
33
32
  async getTask(id) {
34
- zod_1.z.string().min(1).parse(id);
33
+ validators_1.IdSchema.parse(id);
35
34
  const response = await (0, http_client_1.request)({
36
35
  httpMethod: 'GET',
37
36
  baseUri: this.syncApiBase,
@@ -155,7 +154,7 @@ class TaskClient extends base_client_1.BaseClient {
155
154
  return (0, validators_1.validateTask)(response.data);
156
155
  }
157
156
  async updateTask(id, args, requestId) {
158
- zod_1.z.string().min(1).parse(id);
157
+ validators_1.IdSchema.parse(id);
159
158
  // Translate SDK alias for due-date clearing to Todoist's accepted payload value.
160
159
  const normalizedArgs = args.dueString === null ? Object.assign(Object.assign({}, args), { dueString: 'no date' }) : args;
161
160
  // Process content if both content and isUncompletable are provided
@@ -203,7 +202,7 @@ class TaskClient extends base_client_1.BaseClient {
203
202
  return (0, validators_1.validateTaskArray)(syncTasks);
204
203
  }
205
204
  async moveTask(id, args, requestId) {
206
- zod_1.z.string().min(1).parse(id);
205
+ validators_1.IdSchema.parse(id);
207
206
  const response = await (0, http_client_1.request)({
208
207
  httpMethod: 'POST',
209
208
  baseUri: this.syncApiBase,
@@ -216,7 +215,7 @@ class TaskClient extends base_client_1.BaseClient {
216
215
  return (0, validators_1.validateTask)(response.data);
217
216
  }
218
217
  async closeTask(id, requestId) {
219
- zod_1.z.string().min(1).parse(id);
218
+ validators_1.IdSchema.parse(id);
220
219
  const response = await (0, http_client_1.request)({
221
220
  httpMethod: 'POST',
222
221
  baseUri: this.syncApiBase,
@@ -228,7 +227,7 @@ class TaskClient extends base_client_1.BaseClient {
228
227
  return (0, http_client_1.isSuccess)(response);
229
228
  }
230
229
  async reopenTask(id, requestId) {
231
- zod_1.z.string().min(1).parse(id);
230
+ validators_1.IdSchema.parse(id);
232
231
  const response = await (0, http_client_1.request)({
233
232
  httpMethod: 'POST',
234
233
  baseUri: this.syncApiBase,
@@ -240,7 +239,7 @@ class TaskClient extends base_client_1.BaseClient {
240
239
  return (0, http_client_1.isSuccess)(response);
241
240
  }
242
241
  async deleteTask(id, requestId) {
243
- zod_1.z.string().min(1).parse(id);
242
+ validators_1.IdSchema.parse(id);
244
243
  const response = await (0, http_client_1.request)({
245
244
  httpMethod: 'DELETE',
246
245
  baseUri: this.syncApiBase,
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UiExtensionClient = 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 case_conversion_1 = require("../utils/case-conversion");
@@ -17,7 +16,7 @@ const base_client_1 = require("./base-client");
17
16
  */
18
17
  class UiExtensionClient extends base_client_1.BaseClient {
19
18
  async getUiExtension(uiExtensionId, requestId) {
20
- zod_1.z.string().min(1).parse(uiExtensionId);
19
+ validators_1.IdSchema.parse(uiExtensionId);
21
20
  const response = await (0, http_client_1.request)({
22
21
  httpMethod: 'GET',
23
22
  baseUri: this.apiRootBase,
@@ -40,7 +39,7 @@ class UiExtensionClient extends base_client_1.BaseClient {
40
39
  return (0, validators_1.validateUiExtensionArray)(response.data);
41
40
  }
42
41
  async getUiExtensionsForApp(appId, requestId) {
43
- zod_1.z.string().min(1).parse(appId);
42
+ validators_1.IdSchema.parse(appId);
44
43
  const response = await (0, http_client_1.request)({
45
44
  httpMethod: 'GET',
46
45
  baseUri: this.apiRootBase,
@@ -64,7 +63,7 @@ class UiExtensionClient extends base_client_1.BaseClient {
64
63
  return (0, validators_1.validateUiExtension)(response.data);
65
64
  }
66
65
  async updateUiExtension(uiExtensionId, args, requestId) {
67
- zod_1.z.string().min(1).parse(uiExtensionId);
66
+ validators_1.IdSchema.parse(uiExtensionId);
68
67
  const response = await (0, http_client_1.request)({
69
68
  httpMethod: 'PATCH',
70
69
  baseUri: this.apiRootBase,
@@ -77,7 +76,7 @@ class UiExtensionClient extends base_client_1.BaseClient {
77
76
  return (0, validators_1.validateUiExtension)(response.data);
78
77
  }
79
78
  async deleteUiExtension(uiExtensionId, requestId) {
80
- zod_1.z.string().min(1).parse(uiExtensionId);
79
+ validators_1.IdSchema.parse(uiExtensionId);
81
80
  const response = await (0, http_client_1.request)({
82
81
  httpMethod: 'DELETE',
83
82
  baseUri: this.apiRootBase,
@@ -12,7 +12,6 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.WorkspaceClient = void 0;
15
- const zod_1 = require("zod");
16
15
  const endpoints_1 = require("../consts/endpoints");
17
16
  const http_client_1 = require("../transport/http-client");
18
17
  const multipart_upload_1 = require("../utils/multipart-upload");
@@ -199,7 +198,7 @@ class WorkspaceClient extends base_client_1.BaseClient {
199
198
  return (0, validators_1.validateWorkspaceArray)(response.data);
200
199
  }
201
200
  async getWorkspace(id, requestId) {
202
- zod_1.z.string().min(1).parse(id);
201
+ validators_1.IdSchema.parse(id);
203
202
  const response = await (0, http_client_1.request)({
204
203
  httpMethod: 'GET',
205
204
  baseUri: this.syncApiBase,
@@ -223,7 +222,7 @@ class WorkspaceClient extends base_client_1.BaseClient {
223
222
  return (0, validators_1.validateWorkspace)(response.data);
224
223
  }
225
224
  async updateWorkspace(id, args, requestId) {
226
- zod_1.z.string().min(1).parse(id);
225
+ validators_1.IdSchema.parse(id);
227
226
  const response = await (0, http_client_1.request)({
228
227
  httpMethod: 'POST',
229
228
  baseUri: this.syncApiBase,
@@ -236,7 +235,7 @@ class WorkspaceClient extends base_client_1.BaseClient {
236
235
  return (0, validators_1.validateWorkspace)(response.data);
237
236
  }
238
237
  async deleteWorkspace(id, requestId) {
239
- zod_1.z.string().min(1).parse(id);
238
+ validators_1.IdSchema.parse(id);
240
239
  const response = await (0, http_client_1.request)({
241
240
  httpMethod: 'DELETE',
242
241
  baseUri: this.syncApiBase,
@@ -36,3 +36,4 @@ __exportStar(require("./http"), exports);
36
36
  __exportStar(require("./sync"), exports);
37
37
  __exportStar(require("./apps"), exports);
38
38
  __exportStar(require("./ui-extensions"), exports);
39
+ __exportStar(require("./webhooks"), exports);
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseWebhookEnvelopeShape = exports.WebhookInitiatorSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const types_1 = require("../apps/types");
6
+ /**
7
+ * Collaborator info for the user that triggered a webhook event.
8
+ * @see https://developer.todoist.com/sync/v1/#webhooks
9
+ */
10
+ exports.WebhookInitiatorSchema = zod_1.z.object({
11
+ id: zod_1.z.string(),
12
+ fullName: zod_1.z.string(),
13
+ email: zod_1.z.string(),
14
+ imageId: zod_1.z.string().nullable(),
15
+ isPremium: zod_1.z.boolean(),
16
+ });
17
+ /**
18
+ * Fields common to every webhook payload, regardless of `eventName`.
19
+ * Meant to be spread into per-event variant schemas.
20
+ */
21
+ exports.BaseWebhookEnvelopeShape = {
22
+ version: types_1.WebhookVersionSchema,
23
+ userId: zod_1.z.string(),
24
+ initiator: exports.WebhookInitiatorSchema,
25
+ triggeredAt: zod_1.z.coerce.date(),
26
+ };
@@ -0,0 +1,19 @@
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("./envelope"), exports);
18
+ __exportStar(require("./tasks"), exports);
19
+ __exportStar(require("./types"), exports);