@doist/todoist-sdk 14.2.0 → 15.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/dist/esm/utils/index.js +1 -1
  2. package/dist/esm/utils/url-helpers.js +151 -23
  3. package/dist/types/utils/index.d.ts +2 -1
  4. package/dist/types/utils/url-helpers.d.ts +88 -0
  5. package/package.json +5 -10
  6. package/dist/cjs/authentication.js +0 -317
  7. package/dist/cjs/clients/activity-client.js +0 -63
  8. package/dist/cjs/clients/app-client.js +0 -345
  9. package/dist/cjs/clients/backup-client.js +0 -47
  10. package/dist/cjs/clients/base-client.js +0 -31
  11. package/dist/cjs/clients/billing-client.js +0 -152
  12. package/dist/cjs/clients/comment-client.js +0 -91
  13. package/dist/cjs/clients/email-client.js +0 -43
  14. package/dist/cjs/clients/folder-client.js +0 -79
  15. package/dist/cjs/clients/id-mapping-client.js +0 -39
  16. package/dist/cjs/clients/insights-client.js +0 -87
  17. package/dist/cjs/clients/label-client.js +0 -126
  18. package/dist/cjs/clients/productivity-client.js +0 -27
  19. package/dist/cjs/clients/project-client.js +0 -235
  20. package/dist/cjs/clients/reminder-client.js +0 -198
  21. package/dist/cjs/clients/section-client.js +0 -117
  22. package/dist/cjs/clients/task-client.js +0 -254
  23. package/dist/cjs/clients/template-client.js +0 -88
  24. package/dist/cjs/clients/ui-extension-client.js +0 -107
  25. package/dist/cjs/clients/upload-client.js +0 -155
  26. package/dist/cjs/clients/view-options-client.js +0 -25
  27. package/dist/cjs/clients/workspace-client.js +0 -366
  28. package/dist/cjs/consts/endpoints.js +0 -224
  29. package/dist/cjs/index.js +0 -24
  30. package/dist/cjs/package.json +0 -1
  31. package/dist/cjs/test-utils/asserts.js +0 -11
  32. package/dist/cjs/test-utils/msw-setup.js +0 -97
  33. package/dist/cjs/test-utils/obsidian-fetch-adapter.js +0 -54
  34. package/dist/cjs/test-utils/test-defaults.js +0 -371
  35. package/dist/cjs/test-utils/transport-seam.js +0 -17
  36. package/dist/cjs/test-utils/webhook-fixtures.js +0 -32
  37. package/dist/cjs/todoist-api.js +0 -1711
  38. package/dist/cjs/transport/fetch-with-retry.js +0 -219
  39. package/dist/cjs/transport/http-client.js +0 -134
  40. package/dist/cjs/transport/http-dispatcher.js +0 -198
  41. package/dist/cjs/transport/sync-request.js +0 -83
  42. package/dist/cjs/types/activity/index.js +0 -18
  43. package/dist/cjs/types/activity/requests.js +0 -2
  44. package/dist/cjs/types/activity/types.js +0 -28
  45. package/dist/cjs/types/apps/index.js +0 -18
  46. package/dist/cjs/types/apps/requests.js +0 -2
  47. package/dist/cjs/types/apps/types.js +0 -254
  48. package/dist/cjs/types/backups/index.js +0 -18
  49. package/dist/cjs/types/backups/requests.js +0 -2
  50. package/dist/cjs/types/backups/types.js +0 -8
  51. package/dist/cjs/types/billing/index.js +0 -18
  52. package/dist/cjs/types/billing/requests.js +0 -2
  53. package/dist/cjs/types/billing/types.js +0 -92
  54. package/dist/cjs/types/comments/index.js +0 -18
  55. package/dist/cjs/types/comments/requests.js +0 -2
  56. package/dist/cjs/types/comments/types.js +0 -60
  57. package/dist/cjs/types/common.js +0 -10
  58. package/dist/cjs/types/emails/index.js +0 -17
  59. package/dist/cjs/types/emails/requests.js +0 -5
  60. package/dist/cjs/types/errors.js +0 -29
  61. package/dist/cjs/types/folders/index.js +0 -17
  62. package/dist/cjs/types/folders/requests.js +0 -2
  63. package/dist/cjs/types/http.js +0 -24
  64. package/dist/cjs/types/id-mappings/index.js +0 -18
  65. package/dist/cjs/types/id-mappings/requests.js +0 -20
  66. package/dist/cjs/types/id-mappings/types.js +0 -12
  67. package/dist/cjs/types/index.js +0 -40
  68. package/dist/cjs/types/insights/index.js +0 -18
  69. package/dist/cjs/types/insights/requests.js +0 -2
  70. package/dist/cjs/types/insights/types.js +0 -80
  71. package/dist/cjs/types/labels/index.js +0 -18
  72. package/dist/cjs/types/labels/requests.js +0 -2
  73. package/dist/cjs/types/labels/types.js +0 -11
  74. package/dist/cjs/types/productivity/index.js +0 -17
  75. package/dist/cjs/types/productivity/types.js +0 -68
  76. package/dist/cjs/types/projects/index.js +0 -18
  77. package/dist/cjs/types/projects/requests.js +0 -2
  78. package/dist/cjs/types/projects/types.js +0 -66
  79. package/dist/cjs/types/reminders/index.js +0 -17
  80. package/dist/cjs/types/reminders/requests.js +0 -95
  81. package/dist/cjs/types/sections/index.js +0 -18
  82. package/dist/cjs/types/sections/requests.js +0 -2
  83. package/dist/cjs/types/sections/types.js +0 -25
  84. package/dist/cjs/types/sync/commands/calendars.js +0 -2
  85. package/dist/cjs/types/sync/commands/filters.js +0 -2
  86. package/dist/cjs/types/sync/commands/folders.js +0 -2
  87. package/dist/cjs/types/sync/commands/index.js +0 -34
  88. package/dist/cjs/types/sync/commands/labels.js +0 -5
  89. package/dist/cjs/types/sync/commands/notes.js +0 -2
  90. package/dist/cjs/types/sync/commands/notifications.js +0 -2
  91. package/dist/cjs/types/sync/commands/others.js +0 -2
  92. package/dist/cjs/types/sync/commands/project-view-options.js +0 -2
  93. package/dist/cjs/types/sync/commands/projects.js +0 -2
  94. package/dist/cjs/types/sync/commands/reminders.js +0 -2
  95. package/dist/cjs/types/sync/commands/sections.js +0 -2
  96. package/dist/cjs/types/sync/commands/shared.js +0 -20
  97. package/dist/cjs/types/sync/commands/sharing.js +0 -2
  98. package/dist/cjs/types/sync/commands/tasks.js +0 -2
  99. package/dist/cjs/types/sync/commands/view-options.js +0 -2
  100. package/dist/cjs/types/sync/commands/workspace-filters.js +0 -2
  101. package/dist/cjs/types/sync/commands/workspaces.js +0 -2
  102. package/dist/cjs/types/sync/index.js +0 -22
  103. package/dist/cjs/types/sync/request.js +0 -2
  104. package/dist/cjs/types/sync/resource-types.js +0 -39
  105. package/dist/cjs/types/sync/resources/calendars.js +0 -27
  106. package/dist/cjs/types/sync/resources/collaborators.js +0 -21
  107. package/dist/cjs/types/sync/resources/completed-info.js +0 -24
  108. package/dist/cjs/types/sync/resources/filters.js +0 -14
  109. package/dist/cjs/types/sync/resources/folders.js +0 -12
  110. package/dist/cjs/types/sync/resources/index.js +0 -32
  111. package/dist/cjs/types/sync/resources/live-notifications.js +0 -38
  112. package/dist/cjs/types/sync/resources/notes.js +0 -21
  113. package/dist/cjs/types/sync/resources/reminders.js +0 -50
  114. package/dist/cjs/types/sync/resources/suggestions.js +0 -36
  115. package/dist/cjs/types/sync/resources/tooltips.js +0 -8
  116. package/dist/cjs/types/sync/resources/user-plan-limits.js +0 -20
  117. package/dist/cjs/types/sync/resources/user-settings.js +0 -40
  118. package/dist/cjs/types/sync/resources/user.js +0 -110
  119. package/dist/cjs/types/sync/resources/view-options.js +0 -86
  120. package/dist/cjs/types/sync/resources/workspace-filters.js +0 -19
  121. package/dist/cjs/types/sync/resources/workspaces.js +0 -72
  122. package/dist/cjs/types/sync/response.js +0 -54
  123. package/dist/cjs/types/sync/user-preferences.js +0 -71
  124. package/dist/cjs/types/tasks/index.js +0 -18
  125. package/dist/cjs/types/tasks/requests.js +0 -2
  126. package/dist/cjs/types/tasks/types.js +0 -59
  127. package/dist/cjs/types/templates/index.js +0 -17
  128. package/dist/cjs/types/templates/requests.js +0 -2
  129. package/dist/cjs/types/ui-extensions/index.js +0 -18
  130. package/dist/cjs/types/ui-extensions/requests.js +0 -2
  131. package/dist/cjs/types/ui-extensions/types.js +0 -77
  132. package/dist/cjs/types/uploads/index.js +0 -17
  133. package/dist/cjs/types/uploads/requests.js +0 -2
  134. package/dist/cjs/types/users/index.js +0 -17
  135. package/dist/cjs/types/users/types.js +0 -51
  136. package/dist/cjs/types/webhooks/comments.js +0 -96
  137. package/dist/cjs/types/webhooks/envelope.js +0 -26
  138. package/dist/cjs/types/webhooks/filters.js +0 -30
  139. package/dist/cjs/types/webhooks/index.js +0 -25
  140. package/dist/cjs/types/webhooks/labels.js +0 -54
  141. package/dist/cjs/types/webhooks/projects.js +0 -36
  142. package/dist/cjs/types/webhooks/reminders.js +0 -35
  143. package/dist/cjs/types/webhooks/sections.js +0 -53
  144. package/dist/cjs/types/webhooks/tasks.js +0 -68
  145. package/dist/cjs/types/webhooks/types.js +0 -55
  146. package/dist/cjs/types/workspaces/index.js +0 -18
  147. package/dist/cjs/types/workspaces/requests.js +0 -2
  148. package/dist/cjs/types/workspaces/types.js +0 -154
  149. package/dist/cjs/utils/activity-helpers.js +0 -58
  150. package/dist/cjs/utils/case-conversion.js +0 -69
  151. package/dist/cjs/utils/colors.js +0 -143
  152. package/dist/cjs/utils/file-response.js +0 -32
  153. package/dist/cjs/utils/headers.js +0 -16
  154. package/dist/cjs/utils/index.js +0 -31
  155. package/dist/cjs/utils/multipart-upload.js +0 -293
  156. package/dist/cjs/utils/processing-helpers.js +0 -18
  157. package/dist/cjs/utils/project-helpers.js +0 -20
  158. package/dist/cjs/utils/request-helpers.js +0 -21
  159. package/dist/cjs/utils/sanitization.js +0 -116
  160. package/dist/cjs/utils/sync-helpers.js +0 -22
  161. package/dist/cjs/utils/task-sorting.js +0 -281
  162. package/dist/cjs/utils/uncompletable-helpers.js +0 -60
  163. package/dist/cjs/utils/url-helpers.js +0 -74
  164. package/dist/cjs/utils/validators.js +0 -108
  165. package/dist/cjs/utils/view-options.js +0 -19
  166. package/dist/cjs/utils/webhook-parser.js +0 -60
@@ -1,345 +0,0 @@
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.AppClient = void 0;
15
- const zod_1 = require("zod");
16
- const endpoints_1 = require("../consts/endpoints");
17
- const http_client_1 = require("../transport/http-client");
18
- const apps_1 = require("../types/apps");
19
- const multipart_upload_1 = require("../utils/multipart-upload");
20
- const validators_1 = require("../utils/validators");
21
- const base_client_1 = require("./base-client");
22
- /**
23
- * Internal sub-client handling all developer-app management endpoints
24
- * (apps, secrets, tokens, webhooks, installations, user authorizations).
25
- * All endpoints require the `dev:app_console` OAuth scope.
26
- *
27
- * Instantiated by `TodoistApi`; every public app-management method on
28
- * `TodoistApi` delegates here. See `todoist-api.ts` for user-facing JSDoc.
29
- */
30
- class AppClient extends base_client_1.BaseClient {
31
- async getApps(requestId) {
32
- const response = await (0, http_client_1.request)({
33
- httpMethod: 'GET',
34
- baseUri: this.apiRootBase,
35
- relativePath: endpoints_1.ENDPOINT_REST_APPS,
36
- apiToken: this.authToken,
37
- customFetch: this.customFetch,
38
- requestId: requestId,
39
- });
40
- return (0, validators_1.validateAppArray)(response.data);
41
- }
42
- async getApp(appId, requestId) {
43
- validators_1.IdSchema.parse(appId);
44
- const response = await (0, http_client_1.request)({
45
- httpMethod: 'GET',
46
- baseUri: this.apiRootBase,
47
- relativePath: (0, endpoints_1.getAppEndpoint)(appId),
48
- apiToken: this.authToken,
49
- customFetch: this.customFetch,
50
- requestId: requestId,
51
- });
52
- return (0, validators_1.validateAppWithUserCount)(response.data);
53
- }
54
- async addApp(args, requestId) {
55
- const response = await (0, http_client_1.request)({
56
- httpMethod: 'POST',
57
- baseUri: this.apiRootBase,
58
- relativePath: endpoints_1.ENDPOINT_REST_APPS,
59
- apiToken: this.authToken,
60
- customFetch: this.customFetch,
61
- payload: args,
62
- requestId: requestId,
63
- });
64
- return (0, validators_1.validateApp)(response.data);
65
- }
66
- async updateApp(appId, args, requestId) {
67
- validators_1.IdSchema.parse(appId);
68
- const { appTokenScopes } = args, rest = __rest(args, ["appTokenScopes"]);
69
- const payload = Object.assign({}, rest);
70
- if (appTokenScopes !== undefined) {
71
- payload.appTokenScopes = appTokenScopes === null ? null : appTokenScopes.join(',');
72
- }
73
- const response = await (0, http_client_1.request)({
74
- httpMethod: 'POST',
75
- baseUri: this.apiRootBase,
76
- relativePath: (0, endpoints_1.getAppEndpoint)(appId),
77
- apiToken: this.authToken,
78
- customFetch: this.customFetch,
79
- payload: payload,
80
- requestId: requestId,
81
- });
82
- return (0, validators_1.validateAppWithUserCount)(response.data);
83
- }
84
- async deleteApp(appId, requestId) {
85
- validators_1.IdSchema.parse(appId);
86
- const response = await (0, http_client_1.request)({
87
- httpMethod: 'DELETE',
88
- baseUri: this.apiRootBase,
89
- relativePath: (0, endpoints_1.getAppEndpoint)(appId),
90
- apiToken: this.authToken,
91
- customFetch: this.customFetch,
92
- requestId: requestId,
93
- });
94
- return (0, http_client_1.isSuccess)(response);
95
- }
96
- async getAppSecrets(appId, requestId) {
97
- validators_1.IdSchema.parse(appId);
98
- const response = await (0, http_client_1.request)({
99
- httpMethod: 'GET',
100
- baseUri: this.apiRootBase,
101
- relativePath: (0, endpoints_1.getAppSecretsEndpoint)(appId),
102
- apiToken: this.authToken,
103
- customFetch: this.customFetch,
104
- requestId: requestId,
105
- });
106
- return (0, validators_1.validateAppSecrets)(response.data);
107
- }
108
- async resetAppClientSecret(appId, requestId) {
109
- validators_1.IdSchema.parse(appId);
110
- const response = await (0, http_client_1.request)({
111
- httpMethod: 'DELETE',
112
- baseUri: this.apiRootBase,
113
- relativePath: (0, endpoints_1.getAppClientSecretEndpoint)(appId),
114
- apiToken: this.authToken,
115
- customFetch: this.customFetch,
116
- requestId: requestId,
117
- });
118
- return (0, validators_1.validateAppWithUserCount)(response.data);
119
- }
120
- async revokeAppTokens(appId, requestId) {
121
- validators_1.IdSchema.parse(appId);
122
- const response = await (0, http_client_1.request)({
123
- httpMethod: 'DELETE',
124
- baseUri: this.apiRootBase,
125
- relativePath: (0, endpoints_1.getAppTokensEndpoint)(appId),
126
- apiToken: this.authToken,
127
- customFetch: this.customFetch,
128
- requestId: requestId,
129
- });
130
- return (0, validators_1.validateAppWithUserCount)(response.data);
131
- }
132
- async uploadAppIcon({ appId, file, fileName = '', size = 'medium' }, requestId) {
133
- validators_1.IdSchema.parse(appId);
134
- if (Buffer.isBuffer(file) && file.length === 0) {
135
- throw new Error('Cannot upload empty image file');
136
- }
137
- const data = await (0, multipart_upload_1.uploadMultipartFile)({
138
- baseUrl: this.apiRootBase,
139
- authToken: this.authToken,
140
- endpoint: (0, endpoints_1.getAppIconEndpoint)(appId, size),
141
- file,
142
- fileName,
143
- additionalFields: { file_name: fileName },
144
- requestId: requestId,
145
- customFetch: this.customFetch,
146
- });
147
- return (0, validators_1.validateAppWithUserCount)(data);
148
- }
149
- async getAppTestToken(appId, requestId) {
150
- validators_1.IdSchema.parse(appId);
151
- const response = await (0, http_client_1.request)({
152
- httpMethod: 'GET',
153
- baseUri: this.apiRootBase,
154
- relativePath: (0, endpoints_1.getAppTestTokenEndpoint)(appId),
155
- apiToken: this.authToken,
156
- customFetch: this.customFetch,
157
- requestId: requestId,
158
- });
159
- return (0, validators_1.validateAppTestToken)(response.data);
160
- }
161
- async createAppTestToken(appId, requestId) {
162
- validators_1.IdSchema.parse(appId);
163
- const response = await (0, http_client_1.request)({
164
- httpMethod: 'PUT',
165
- baseUri: this.apiRootBase,
166
- relativePath: (0, endpoints_1.getAppTestTokenEndpoint)(appId),
167
- apiToken: this.authToken,
168
- customFetch: this.customFetch,
169
- requestId: requestId,
170
- });
171
- return (0, validators_1.validateAppTestToken)(response.data);
172
- }
173
- async getAppDistributionToken(appId, requestId) {
174
- validators_1.IdSchema.parse(appId);
175
- const response = await (0, http_client_1.request)({
176
- httpMethod: 'GET',
177
- baseUri: this.apiRootBase,
178
- relativePath: (0, endpoints_1.getAppDistributionTokenEndpoint)(appId),
179
- apiToken: this.authToken,
180
- customFetch: this.customFetch,
181
- requestId: requestId,
182
- });
183
- return (0, validators_1.validateAppDistributionToken)(response.data);
184
- }
185
- async getAppVerificationToken(appId, requestId) {
186
- validators_1.IdSchema.parse(appId);
187
- const response = await (0, http_client_1.request)({
188
- httpMethod: 'GET',
189
- baseUri: this.apiRootBase,
190
- relativePath: (0, endpoints_1.getAppVerificationTokenEndpoint)(appId),
191
- apiToken: this.authToken,
192
- customFetch: this.customFetch,
193
- requestId: requestId,
194
- });
195
- return (0, validators_1.validateAppVerificationToken)(response.data);
196
- }
197
- async resetAppVerificationToken(appId, requestId) {
198
- validators_1.IdSchema.parse(appId);
199
- const response = await (0, http_client_1.request)({
200
- httpMethod: 'DELETE',
201
- baseUri: this.apiRootBase,
202
- relativePath: (0, endpoints_1.getAppVerificationTokenEndpoint)(appId),
203
- apiToken: this.authToken,
204
- customFetch: this.customFetch,
205
- requestId: requestId,
206
- });
207
- return (0, validators_1.validateAppVerificationToken)(response.data);
208
- }
209
- async getAppByDistributionToken(distributionToken, requestId) {
210
- zod_1.z.string().min(1).parse(distributionToken);
211
- const response = await (0, http_client_1.request)({
212
- httpMethod: 'GET',
213
- baseUri: this.apiRootBase,
214
- relativePath: (0, endpoints_1.getAppByDistributionTokenEndpoint)(distributionToken),
215
- apiToken: this.authToken,
216
- customFetch: this.customFetch,
217
- requestId: requestId,
218
- });
219
- return (0, validators_1.validateAppByDistributionToken)(response.data);
220
- }
221
- // --- App webhooks ---
222
- async getAppWebhook(appId, requestId) {
223
- validators_1.IdSchema.parse(appId);
224
- const response = await (0, http_client_1.request)({
225
- httpMethod: 'GET',
226
- baseUri: this.apiRootBase,
227
- relativePath: (0, endpoints_1.getAppWebhookEndpoint)(appId),
228
- apiToken: this.authToken,
229
- customFetch: this.customFetch,
230
- requestId: requestId,
231
- });
232
- return response.data ? (0, validators_1.validateAppWebhook)(response.data) : null;
233
- }
234
- async updateAppWebhook(args, requestId) {
235
- const { appId, events } = args, rest = __rest(args, ["appId", "events"]);
236
- const response = await (0, http_client_1.request)({
237
- httpMethod: 'POST',
238
- baseUri: this.apiRootBase,
239
- relativePath: (0, endpoints_1.getAppWebhookEndpoint)(appId),
240
- apiToken: this.authToken,
241
- customFetch: this.customFetch,
242
- payload: Object.assign(Object.assign({}, rest), { events: events.map(apps_1.webhookEventToWireName) }),
243
- requestId: requestId,
244
- });
245
- return (0, validators_1.validateAppWebhook)(response.data);
246
- }
247
- async deleteAppWebhook(appId, requestId) {
248
- validators_1.IdSchema.parse(appId);
249
- const response = await (0, http_client_1.request)({
250
- httpMethod: 'DELETE',
251
- baseUri: this.apiRootBase,
252
- relativePath: (0, endpoints_1.getAppWebhookEndpoint)(appId),
253
- apiToken: this.authToken,
254
- customFetch: this.customFetch,
255
- requestId: requestId,
256
- });
257
- return (0, http_client_1.isSuccess)(response);
258
- }
259
- // --- App installations ---
260
- async getAppInstallations(requestId) {
261
- const response = await (0, http_client_1.request)({
262
- httpMethod: 'GET',
263
- baseUri: this.apiRootBase,
264
- relativePath: endpoints_1.ENDPOINT_REST_APPS_INSTALLATIONS,
265
- apiToken: this.authToken,
266
- customFetch: this.customFetch,
267
- requestId: requestId,
268
- });
269
- return (0, validators_1.validateAppInstallationArray)(response.data);
270
- }
271
- async installApp(args, requestId) {
272
- const response = await (0, http_client_1.request)({
273
- httpMethod: 'POST',
274
- baseUri: this.apiRootBase,
275
- relativePath: endpoints_1.ENDPOINT_REST_APPS_INSTALLATIONS,
276
- apiToken: this.authToken,
277
- customFetch: this.customFetch,
278
- payload: args,
279
- requestId: requestId,
280
- });
281
- return (0, validators_1.validateAppInstallation)(response.data);
282
- }
283
- async getAppInstallation(installationId, requestId) {
284
- validators_1.IdSchema.parse(installationId);
285
- const response = await (0, http_client_1.request)({
286
- httpMethod: 'GET',
287
- baseUri: this.apiRootBase,
288
- relativePath: (0, endpoints_1.getAppInstallationEndpoint)(installationId),
289
- apiToken: this.authToken,
290
- customFetch: this.customFetch,
291
- requestId: requestId,
292
- });
293
- return (0, validators_1.validateAppInstallation)(response.data);
294
- }
295
- async updateAppInstallation(installationId, args, requestId) {
296
- validators_1.IdSchema.parse(installationId);
297
- const response = await (0, http_client_1.request)({
298
- httpMethod: 'POST',
299
- baseUri: this.apiRootBase,
300
- relativePath: (0, endpoints_1.getAppInstallationEndpoint)(installationId),
301
- apiToken: this.authToken,
302
- customFetch: this.customFetch,
303
- payload: args,
304
- requestId: requestId,
305
- });
306
- return (0, validators_1.validateAppInstallation)(response.data);
307
- }
308
- async uninstallApp(installationId, requestId) {
309
- validators_1.IdSchema.parse(installationId);
310
- const response = await (0, http_client_1.request)({
311
- httpMethod: 'DELETE',
312
- baseUri: this.apiRootBase,
313
- relativePath: (0, endpoints_1.getAppInstallationEndpoint)(installationId),
314
- apiToken: this.authToken,
315
- customFetch: this.customFetch,
316
- requestId: requestId,
317
- });
318
- return (0, http_client_1.isSuccess)(response);
319
- }
320
- // --- User authorizations ---
321
- async getUserAuthorizations(requestId) {
322
- const response = await (0, http_client_1.request)({
323
- httpMethod: 'GET',
324
- baseUri: this.apiRootBase,
325
- relativePath: endpoints_1.ENDPOINT_REST_USER_AUTHORIZATIONS,
326
- apiToken: this.authToken,
327
- customFetch: this.customFetch,
328
- requestId: requestId,
329
- });
330
- return (0, validators_1.validateUserAuthorizationArray)(response.data);
331
- }
332
- async revokeUserAuthorization(args, requestId) {
333
- const response = await (0, http_client_1.request)({
334
- httpMethod: 'POST',
335
- baseUri: this.apiRootBase,
336
- relativePath: endpoints_1.ENDPOINT_REST_USER_AUTHORIZATIONS_DELETE,
337
- apiToken: this.authToken,
338
- customFetch: this.customFetch,
339
- payload: args,
340
- requestId: requestId,
341
- });
342
- return (0, http_client_1.isSuccess)(response);
343
- }
344
- }
345
- exports.AppClient = AppClient;
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BackupClient = void 0;
4
- const endpoints_1 = require("../consts/endpoints");
5
- const http_client_1 = require("../transport/http-client");
6
- const file_response_1 = require("../utils/file-response");
7
- const validators_1 = require("../utils/validators");
8
- const base_client_1 = require("./base-client");
9
- /**
10
- * Internal sub-client handling backup-domain endpoints.
11
- *
12
- * Instantiated by `TodoistApi`; every public backup method on
13
- * `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
14
- * JSDoc.
15
- */
16
- class BackupClient extends base_client_1.BaseClient {
17
- async getBackups(args = {}) {
18
- const response = await (0, http_client_1.request)({
19
- httpMethod: 'GET',
20
- baseUri: this.syncApiBase,
21
- relativePath: endpoints_1.ENDPOINT_REST_BACKUPS,
22
- apiToken: this.authToken,
23
- customFetch: this.customFetch,
24
- payload: args,
25
- });
26
- return (0, validators_1.validateBackupArray)(response.data);
27
- }
28
- async downloadBackup(args) {
29
- const url = `${this.syncApiBase}${endpoints_1.ENDPOINT_REST_BACKUPS_DOWNLOAD}?file=${encodeURIComponent(args.file)}`;
30
- const fetchOptions = {
31
- headers: { Authorization: `Bearer ${this.authToken}` },
32
- };
33
- if (this.customFetch) {
34
- const response = await this.customFetch(url, fetchOptions);
35
- if (!response.ok) {
36
- throw new Error(`Failed to download backup: ${response.status} ${response.statusText}`);
37
- }
38
- return (0, file_response_1.wrapAsFileResponse)(response, 'downloadBackup');
39
- }
40
- const response = await fetch(url, fetchOptions);
41
- if (!response.ok) {
42
- throw new Error(`Failed to download backup: ${response.status} ${response.statusText}`);
43
- }
44
- return (0, file_response_1.wrapAsFileResponse)(response, 'downloadBackup');
45
- }
46
- }
47
- exports.BackupClient = BackupClient;
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseClient = void 0;
4
- /**
5
- * Internal base class for every domain sub-client (tasks, projects, …).
6
- *
7
- * Not exported from the package — sub-clients are an implementation detail
8
- * of `TodoistApi`. Holds the three pieces of HTTP identity every sub-client
9
- * needs and exposes a typed accessor to feed the Sync API helper.
10
- *
11
- * The constructor takes a {@link SyncRequestContext} — the same record
12
- * shape used by `performSyncRequest` — so there is a single type describing
13
- * "the HTTP identity an SDK component needs", not two types that must stay
14
- * in sync.
15
- */
16
- class BaseClient {
17
- constructor(context) {
18
- this.authToken = context.authToken;
19
- this.syncApiBase = context.syncApiBase;
20
- this.apiRootBase = new URL('/', context.syncApiBase).toString();
21
- this.customFetch = context.customFetch;
22
- }
23
- get syncContext() {
24
- return {
25
- authToken: this.authToken,
26
- syncApiBase: this.syncApiBase,
27
- customFetch: this.customFetch,
28
- };
29
- }
30
- }
31
- exports.BaseClient = BaseClient;
@@ -1,152 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BillingClient = void 0;
4
- const endpoints_1 = require("../consts/endpoints");
5
- const http_client_1 = require("../transport/http-client");
6
- const validators_1 = require("../utils/validators");
7
- const base_client_1 = require("./base-client");
8
- /**
9
- * Internal sub-client handling all billing-domain endpoints.
10
- *
11
- * Instantiated by `TodoistApi`; every public billing method on `TodoistApi`
12
- * delegates here. See `todoist-api.ts` for the user-facing JSDoc.
13
- */
14
- class BillingClient extends base_client_1.BaseClient {
15
- async getSubscriptionInfo() {
16
- const response = await (0, http_client_1.request)({
17
- httpMethod: 'POST',
18
- baseUri: this.syncApiBase,
19
- relativePath: endpoints_1.ENDPOINT_PAYMENTS_SUBSCRIPTION_INFO,
20
- apiToken: this.authToken,
21
- customFetch: this.customFetch,
22
- });
23
- return (0, validators_1.validateSubscriptionInfo)(response.data);
24
- }
25
- async cancelPlan(args, requestId) {
26
- const response = await (0, http_client_1.request)({
27
- httpMethod: 'POST',
28
- baseUri: this.syncApiBase,
29
- relativePath: endpoints_1.ENDPOINT_PAYMENTS_CANCEL_PLAN,
30
- apiToken: this.authToken,
31
- customFetch: this.customFetch,
32
- payload: args,
33
- requestId: requestId,
34
- });
35
- return response.data;
36
- }
37
- async reactivatePlan(requestId) {
38
- const response = await (0, http_client_1.request)({
39
- httpMethod: 'POST',
40
- baseUri: this.syncApiBase,
41
- relativePath: endpoints_1.ENDPOINT_PAYMENTS_REACTIVATE_PLAN,
42
- apiToken: this.authToken,
43
- customFetch: this.customFetch,
44
- requestId: requestId,
45
- });
46
- return (0, validators_1.validateSubscriptionInfo)(response.data);
47
- }
48
- async upgradeToPro(args, requestId) {
49
- const response = await (0, http_client_1.request)({
50
- httpMethod: 'POST',
51
- baseUri: this.syncApiBase,
52
- relativePath: endpoints_1.ENDPOINT_PRO_UPGRADE,
53
- apiToken: this.authToken,
54
- customFetch: this.customFetch,
55
- payload: args,
56
- requestId: requestId,
57
- });
58
- return response.data;
59
- }
60
- async startProTrial(args, requestId) {
61
- const response = await (0, http_client_1.request)({
62
- httpMethod: 'POST',
63
- baseUri: this.syncApiBase,
64
- relativePath: endpoints_1.ENDPOINT_PRO_TRIAL,
65
- apiToken: this.authToken,
66
- customFetch: this.customFetch,
67
- payload: args,
68
- requestId: requestId,
69
- });
70
- return response.data;
71
- }
72
- async createProBillingPortalSession(args, requestId) {
73
- const response = await (0, http_client_1.request)({
74
- httpMethod: 'POST',
75
- baseUri: this.syncApiBase,
76
- relativePath: endpoints_1.ENDPOINT_PRO_BILLING_PORTAL,
77
- apiToken: this.authToken,
78
- customFetch: this.customFetch,
79
- payload: args,
80
- requestId: requestId,
81
- });
82
- return response.data;
83
- }
84
- async getProPlanDetails() {
85
- const response = await (0, http_client_1.request)({
86
- httpMethod: 'GET',
87
- baseUri: this.syncApiBase,
88
- relativePath: endpoints_1.ENDPOINT_PRO_PLAN_DETAILS,
89
- apiToken: this.authToken,
90
- customFetch: this.customFetch,
91
- });
92
- return (0, validators_1.validateProPlanDetails)(response.data);
93
- }
94
- async upgradeWorkspace(args, requestId) {
95
- const response = await (0, http_client_1.request)({
96
- httpMethod: 'POST',
97
- baseUri: this.syncApiBase,
98
- relativePath: endpoints_1.ENDPOINT_WORKSPACE_UPGRADE,
99
- apiToken: this.authToken,
100
- customFetch: this.customFetch,
101
- payload: args,
102
- requestId: requestId,
103
- });
104
- return response.data;
105
- }
106
- async startWorkspaceTrial(args, requestId) {
107
- const response = await (0, http_client_1.request)({
108
- httpMethod: 'POST',
109
- baseUri: this.syncApiBase,
110
- relativePath: endpoints_1.ENDPOINT_WORKSPACE_TRIAL,
111
- apiToken: this.authToken,
112
- customFetch: this.customFetch,
113
- payload: args,
114
- requestId: requestId,
115
- });
116
- return response.data;
117
- }
118
- async createWorkspaceBillingPortalSession(args, requestId) {
119
- const response = await (0, http_client_1.request)({
120
- httpMethod: 'POST',
121
- baseUri: this.syncApiBase,
122
- relativePath: endpoints_1.ENDPOINT_WORKSPACE_BILLING_PORTAL,
123
- apiToken: this.authToken,
124
- customFetch: this.customFetch,
125
- payload: args,
126
- requestId: requestId,
127
- });
128
- return response.data;
129
- }
130
- async getPrices() {
131
- const response = await (0, http_client_1.request)({
132
- httpMethod: 'GET',
133
- baseUri: this.syncApiBase,
134
- relativePath: endpoints_1.ENDPOINT_PRICES,
135
- apiToken: this.authToken,
136
- customFetch: this.customFetch,
137
- });
138
- return (0, validators_1.validatePrices)(response.data);
139
- }
140
- async getPricing(args) {
141
- const response = await (0, http_client_1.request)({
142
- httpMethod: 'GET',
143
- baseUri: this.syncApiBase,
144
- relativePath: endpoints_1.ENDPOINT_PRICING,
145
- apiToken: this.authToken,
146
- customFetch: this.customFetch,
147
- payload: args,
148
- });
149
- return (0, validators_1.validatePricing)(response.data);
150
- }
151
- }
152
- exports.BillingClient = BillingClient;
@@ -1,91 +0,0 @@
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.CommentClient = void 0;
15
- const endpoints_1 = require("../consts/endpoints");
16
- const http_client_1 = require("../transport/http-client");
17
- const request_helpers_1 = require("../utils/request-helpers");
18
- const validators_1 = require("../utils/validators");
19
- const base_client_1 = require("./base-client");
20
- /**
21
- * Internal sub-client handling all comment-domain endpoints.
22
- *
23
- * Instantiated by `TodoistApi`; every public comment method on `TodoistApi`
24
- * delegates here. See `todoist-api.ts` for the user-facing JSDoc.
25
- */
26
- class CommentClient extends base_client_1.BaseClient {
27
- async getComments(args) {
28
- const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
29
- httpMethod: 'GET',
30
- baseUri: this.syncApiBase,
31
- relativePath: endpoints_1.ENDPOINT_REST_COMMENTS,
32
- apiToken: this.authToken,
33
- customFetch: this.customFetch,
34
- payload: args,
35
- });
36
- return {
37
- results: (0, validators_1.validateCommentArray)(results),
38
- nextCursor,
39
- };
40
- }
41
- async getComment(id) {
42
- validators_1.IdSchema.parse(id);
43
- const response = await (0, http_client_1.request)({
44
- httpMethod: 'GET',
45
- baseUri: this.syncApiBase,
46
- relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_COMMENTS, id),
47
- apiToken: this.authToken,
48
- customFetch: this.customFetch,
49
- });
50
- return (0, validators_1.validateComment)(response.data);
51
- }
52
- async addComment(args, requestId) {
53
- const { uidsToNotify } = args, rest = __rest(args, ["uidsToNotify"]);
54
- const response = await (0, http_client_1.request)({
55
- httpMethod: 'POST',
56
- baseUri: this.syncApiBase,
57
- relativePath: endpoints_1.ENDPOINT_REST_COMMENTS,
58
- apiToken: this.authToken,
59
- customFetch: this.customFetch,
60
- payload: Object.assign(Object.assign({}, rest), ((uidsToNotify === null || uidsToNotify === void 0 ? void 0 : uidsToNotify.length) ? { uidsToNotify } : {})),
61
- requestId: requestId,
62
- });
63
- return (0, validators_1.validateComment)(response.data);
64
- }
65
- async updateComment(id, args, requestId) {
66
- validators_1.IdSchema.parse(id);
67
- const response = await (0, http_client_1.request)({
68
- httpMethod: 'POST',
69
- baseUri: this.syncApiBase,
70
- relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_COMMENTS, id),
71
- apiToken: this.authToken,
72
- customFetch: this.customFetch,
73
- payload: args,
74
- requestId: requestId,
75
- });
76
- return (0, validators_1.validateComment)(response.data);
77
- }
78
- async deleteComment(id, requestId) {
79
- validators_1.IdSchema.parse(id);
80
- const response = await (0, http_client_1.request)({
81
- httpMethod: 'DELETE',
82
- baseUri: this.syncApiBase,
83
- relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_COMMENTS, id),
84
- apiToken: this.authToken,
85
- customFetch: this.customFetch,
86
- requestId: requestId,
87
- });
88
- return (0, http_client_1.isSuccess)(response);
89
- }
90
- }
91
- exports.CommentClient = CommentClient;