@doist/todoist-sdk 9.0.0 → 9.1.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 (109) hide show
  1. package/dist/cjs/authentication.js +1 -0
  2. package/dist/cjs/clients/activity-client.js +63 -0
  3. package/dist/cjs/clients/app-client.js +347 -0
  4. package/dist/cjs/clients/backup-client.js +65 -0
  5. package/dist/cjs/clients/base-client.js +30 -0
  6. package/dist/cjs/clients/comment-client.js +92 -0
  7. package/dist/cjs/clients/email-client.js +43 -0
  8. package/dist/cjs/clients/folder-client.js +80 -0
  9. package/dist/cjs/clients/id-mapping-client.js +39 -0
  10. package/dist/cjs/clients/insights-client.js +88 -0
  11. package/dist/cjs/clients/label-client.js +127 -0
  12. package/dist/cjs/clients/productivity-client.js +27 -0
  13. package/dist/cjs/clients/project-client.js +232 -0
  14. package/dist/cjs/clients/reminder-client.js +198 -0
  15. package/dist/cjs/clients/section-client.js +118 -0
  16. package/dist/cjs/clients/task-client.js +255 -0
  17. package/dist/cjs/clients/template-client.js +89 -0
  18. package/dist/cjs/clients/ui-extension-client.js +109 -0
  19. package/dist/cjs/clients/upload-client.js +102 -0
  20. package/dist/cjs/clients/workspace-client.js +367 -0
  21. package/dist/cjs/consts/endpoints.js +66 -1
  22. package/dist/cjs/test-utils/test-defaults.js +77 -1
  23. package/dist/cjs/todoist-api.js +422 -1537
  24. package/dist/cjs/transport/http-client.js +1 -0
  25. package/dist/cjs/transport/sync-request.js +75 -0
  26. package/dist/cjs/types/apps/index.js +18 -0
  27. package/dist/cjs/types/apps/requests.js +2 -0
  28. package/dist/cjs/types/apps/types.js +253 -0
  29. package/dist/cjs/types/index.js +2 -0
  30. package/dist/cjs/types/ui-extensions/index.js +18 -0
  31. package/dist/cjs/types/ui-extensions/requests.js +2 -0
  32. package/dist/cjs/types/ui-extensions/types.js +77 -0
  33. package/dist/cjs/utils/headers.js +16 -0
  34. package/dist/cjs/utils/request-helpers.js +21 -0
  35. package/dist/cjs/utils/validators.js +52 -38
  36. package/dist/esm/authentication.js +1 -0
  37. package/dist/esm/clients/activity-client.js +59 -0
  38. package/dist/esm/clients/app-client.js +343 -0
  39. package/dist/esm/clients/backup-client.js +61 -0
  40. package/dist/esm/clients/base-client.js +26 -0
  41. package/dist/esm/clients/comment-client.js +88 -0
  42. package/dist/esm/clients/email-client.js +39 -0
  43. package/dist/esm/clients/folder-client.js +76 -0
  44. package/dist/esm/clients/id-mapping-client.js +35 -0
  45. package/dist/esm/clients/insights-client.js +84 -0
  46. package/dist/esm/clients/label-client.js +123 -0
  47. package/dist/esm/clients/productivity-client.js +23 -0
  48. package/dist/esm/clients/project-client.js +228 -0
  49. package/dist/esm/clients/reminder-client.js +194 -0
  50. package/dist/esm/clients/section-client.js +114 -0
  51. package/dist/esm/clients/task-client.js +251 -0
  52. package/dist/esm/clients/template-client.js +85 -0
  53. package/dist/esm/clients/ui-extension-client.js +105 -0
  54. package/dist/esm/clients/upload-client.js +98 -0
  55. package/dist/esm/clients/workspace-client.js +363 -0
  56. package/dist/esm/consts/endpoints.js +51 -0
  57. package/dist/esm/test-utils/test-defaults.js +75 -0
  58. package/dist/esm/todoist-api.js +425 -1540
  59. package/dist/esm/transport/http-client.js +1 -0
  60. package/dist/esm/transport/sync-request.js +72 -0
  61. package/dist/esm/types/apps/index.js +2 -0
  62. package/dist/esm/types/apps/requests.js +1 -0
  63. package/dist/esm/types/apps/types.js +248 -0
  64. package/dist/esm/types/index.js +2 -0
  65. package/dist/esm/types/ui-extensions/index.js +2 -0
  66. package/dist/esm/types/ui-extensions/requests.js +1 -0
  67. package/dist/esm/types/ui-extensions/types.js +74 -0
  68. package/dist/esm/utils/headers.js +13 -0
  69. package/dist/esm/utils/request-helpers.js +17 -0
  70. package/dist/esm/utils/validators.js +14 -0
  71. package/dist/types/authentication.d.ts +1 -1
  72. package/dist/types/clients/activity-client.d.ts +12 -0
  73. package/dist/types/clients/app-client.d.ts +37 -0
  74. package/dist/types/clients/backup-client.d.ts +14 -0
  75. package/dist/types/clients/base-client.d.ts +21 -0
  76. package/dist/types/clients/comment-client.d.ts +15 -0
  77. package/dist/types/clients/email-client.d.ts +13 -0
  78. package/dist/types/clients/folder-client.d.ts +16 -0
  79. package/dist/types/clients/id-mapping-client.d.ts +13 -0
  80. package/dist/types/clients/insights-client.d.ts +18 -0
  81. package/dist/types/clients/label-client.d.ts +19 -0
  82. package/dist/types/clients/productivity-client.d.ts +12 -0
  83. package/dist/types/clients/project-client.d.ts +26 -0
  84. package/dist/types/clients/reminder-client.d.ts +25 -0
  85. package/dist/types/clients/section-client.d.ts +18 -0
  86. package/dist/types/clients/task-client.d.ts +25 -0
  87. package/dist/types/clients/template-client.d.ts +17 -0
  88. package/dist/types/clients/ui-extension-client.d.ts +18 -0
  89. package/dist/types/clients/upload-client.d.ts +17 -0
  90. package/dist/types/clients/workspace-client.d.ts +43 -0
  91. package/dist/types/consts/endpoints.d.ts +24 -0
  92. package/dist/types/test-utils/test-defaults.d.ts +16 -1
  93. package/dist/types/todoist-api.d.ts +238 -17
  94. package/dist/types/transport/sync-request.d.ts +27 -0
  95. package/dist/types/types/apps/index.d.ts +2 -0
  96. package/dist/types/types/apps/requests.d.ts +89 -0
  97. package/dist/types/types/apps/types.d.ts +414 -0
  98. package/dist/types/types/http.d.ts +8 -1
  99. package/dist/types/types/index.d.ts +2 -0
  100. package/dist/types/types/sync/resources/user.d.ts +2 -2
  101. package/dist/types/types/sync/response.d.ts +2 -2
  102. package/dist/types/types/sync/user-preferences.d.ts +1 -1
  103. package/dist/types/types/ui-extensions/index.d.ts +2 -0
  104. package/dist/types/types/ui-extensions/requests.d.ts +108 -0
  105. package/dist/types/types/ui-extensions/types.d.ts +185 -0
  106. package/dist/types/utils/headers.d.ts +7 -0
  107. package/dist/types/utils/request-helpers.d.ts +13 -0
  108. package/dist/types/utils/validators.d.ts +223 -0
  109. package/package.json +1 -1
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UiExtensionClient = 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 case_conversion_1 = require("../utils/case-conversion");
8
+ const multipart_upload_1 = require("../utils/multipart-upload");
9
+ const validators_1 = require("../utils/validators");
10
+ const base_client_1 = require("./base-client");
11
+ /**
12
+ * Internal sub-client handling all UI-extension endpoints for developer
13
+ * applications. All endpoints require the `dev:app_console` OAuth scope.
14
+ *
15
+ * Instantiated by `TodoistApi`; every public UI-extension method on
16
+ * `TodoistApi` delegates here. See `todoist-api.ts` for user-facing JSDoc.
17
+ */
18
+ class UiExtensionClient extends base_client_1.BaseClient {
19
+ async getUiExtension(uiExtensionId, requestId) {
20
+ zod_1.z.string().parse(uiExtensionId);
21
+ const response = await (0, http_client_1.request)({
22
+ httpMethod: 'GET',
23
+ baseUri: this.syncApiBase,
24
+ relativePath: (0, endpoints_1.getUiExtensionEndpoint)(uiExtensionId),
25
+ apiToken: this.authToken,
26
+ customFetch: this.customFetch,
27
+ requestId: requestId,
28
+ });
29
+ return (0, validators_1.validateUiExtension)(response.data);
30
+ }
31
+ async getInstalledUiExtensions(requestId) {
32
+ const response = await (0, http_client_1.request)({
33
+ httpMethod: 'GET',
34
+ baseUri: this.syncApiBase,
35
+ relativePath: endpoints_1.ENDPOINT_REST_APPS_UI_EXTENSIONS_INSTALLED,
36
+ apiToken: this.authToken,
37
+ customFetch: this.customFetch,
38
+ requestId: requestId,
39
+ });
40
+ return (0, validators_1.validateUiExtensionArray)(response.data);
41
+ }
42
+ async getUiExtensionsForApp(appId, requestId) {
43
+ zod_1.z.string().parse(appId);
44
+ const response = await (0, http_client_1.request)({
45
+ httpMethod: 'GET',
46
+ baseUri: this.syncApiBase,
47
+ relativePath: (0, endpoints_1.getUiExtensionsByIntegrationEndpoint)(appId),
48
+ apiToken: this.authToken,
49
+ customFetch: this.customFetch,
50
+ requestId: requestId,
51
+ });
52
+ return (0, validators_1.validateUiExtensionArray)(response.data);
53
+ }
54
+ async addUiExtension(args, requestId) {
55
+ const response = await (0, http_client_1.request)({
56
+ httpMethod: 'POST',
57
+ baseUri: this.syncApiBase,
58
+ relativePath: endpoints_1.ENDPOINT_REST_APPS_UI_EXTENSIONS,
59
+ apiToken: this.authToken,
60
+ customFetch: this.customFetch,
61
+ payload: args,
62
+ requestId: requestId,
63
+ });
64
+ return (0, validators_1.validateUiExtension)(response.data);
65
+ }
66
+ async updateUiExtension(uiExtensionId, args, requestId) {
67
+ zod_1.z.string().parse(uiExtensionId);
68
+ const response = await (0, http_client_1.request)({
69
+ httpMethod: 'PATCH',
70
+ baseUri: this.syncApiBase,
71
+ relativePath: (0, endpoints_1.getUiExtensionEndpoint)(uiExtensionId),
72
+ apiToken: this.authToken,
73
+ customFetch: this.customFetch,
74
+ payload: args,
75
+ requestId: requestId,
76
+ });
77
+ return (0, validators_1.validateUiExtension)(response.data);
78
+ }
79
+ async deleteUiExtension(uiExtensionId, requestId) {
80
+ zod_1.z.string().parse(uiExtensionId);
81
+ const response = await (0, http_client_1.request)({
82
+ httpMethod: 'DELETE',
83
+ baseUri: this.syncApiBase,
84
+ relativePath: (0, endpoints_1.getUiExtensionEndpoint)(uiExtensionId),
85
+ apiToken: this.authToken,
86
+ customFetch: this.customFetch,
87
+ requestId: requestId,
88
+ });
89
+ return (0, http_client_1.isSuccess)(response);
90
+ }
91
+ async uploadUiExtensionIcon(args, requestId) {
92
+ var _a;
93
+ if (Buffer.isBuffer(args.file) && args.file.length === 0) {
94
+ throw new Error('Cannot upload empty image file');
95
+ }
96
+ const data = await (0, multipart_upload_1.uploadMultipartFile)({
97
+ baseUrl: this.syncApiBase,
98
+ authToken: this.authToken,
99
+ endpoint: (0, endpoints_1.getUiExtensionIconEndpoint)(args.uiExtensionId),
100
+ file: args.file,
101
+ fileName: args.fileName,
102
+ additionalFields: { file_name: (_a = args.fileName) !== null && _a !== void 0 ? _a : '' },
103
+ requestId: requestId,
104
+ customFetch: this.customFetch,
105
+ });
106
+ return (0, validators_1.validateUiExtension)((0, case_conversion_1.camelCaseKeys)(data));
107
+ }
108
+ }
109
+ exports.UiExtensionClient = UiExtensionClient;
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UploadClient = void 0;
4
+ const endpoints_1 = require("../consts/endpoints");
5
+ const http_client_1 = require("../transport/http-client");
6
+ const headers_1 = require("../utils/headers");
7
+ const multipart_upload_1 = require("../utils/multipart-upload");
8
+ const validators_1 = require("../utils/validators");
9
+ const base_client_1 = require("./base-client");
10
+ /**
11
+ * Internal sub-client handling upload + attachment endpoints
12
+ * (file upload, upload delete, attachment view).
13
+ *
14
+ * Instantiated by `TodoistApi`; every public upload method on
15
+ * `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
16
+ * JSDoc.
17
+ */
18
+ class UploadClient extends base_client_1.BaseClient {
19
+ async uploadFile(args, requestId) {
20
+ const additionalFields = {};
21
+ if (args.projectId) {
22
+ additionalFields.project_id = args.projectId;
23
+ }
24
+ const data = await (0, multipart_upload_1.uploadMultipartFile)({
25
+ baseUrl: this.syncApiBase,
26
+ authToken: this.authToken,
27
+ endpoint: endpoints_1.ENDPOINT_REST_UPLOADS,
28
+ file: args.file,
29
+ fileName: args.fileName,
30
+ additionalFields: additionalFields,
31
+ requestId: requestId,
32
+ customFetch: this.customFetch,
33
+ });
34
+ return (0, validators_1.validateAttachment)(data);
35
+ }
36
+ async deleteUpload(args, requestId) {
37
+ const response = await (0, http_client_1.request)({
38
+ httpMethod: 'DELETE',
39
+ baseUri: this.syncApiBase,
40
+ relativePath: endpoints_1.ENDPOINT_REST_UPLOADS,
41
+ apiToken: this.authToken,
42
+ customFetch: this.customFetch,
43
+ payload: args,
44
+ requestId: requestId,
45
+ });
46
+ return (0, http_client_1.isSuccess)(response);
47
+ }
48
+ async viewAttachment(commentOrUrl) {
49
+ var _a;
50
+ let fileUrl;
51
+ if (typeof commentOrUrl === 'string') {
52
+ fileUrl = commentOrUrl;
53
+ }
54
+ else {
55
+ if (!((_a = commentOrUrl.fileAttachment) === null || _a === void 0 ? void 0 : _a.fileUrl)) {
56
+ throw new Error('Comment does not have a file attachment');
57
+ }
58
+ fileUrl = commentOrUrl.fileAttachment.fileUrl;
59
+ }
60
+ // Validate the URL belongs to Todoist to prevent leaking the auth token
61
+ const urlHostname = new URL(fileUrl).hostname;
62
+ if (!urlHostname.endsWith('.todoist.com')) {
63
+ throw new Error('Attachment URLs must be on a todoist.com domain');
64
+ }
65
+ const fetchOptions = {
66
+ method: 'GET',
67
+ headers: { Authorization: `Bearer ${this.authToken}` },
68
+ };
69
+ if (this.customFetch) {
70
+ const response = await this.customFetch(fileUrl, fetchOptions);
71
+ if (!response.ok) {
72
+ throw new Error(`Failed to fetch attachment: ${response.status} ${response.statusText}`);
73
+ }
74
+ // Convert text to ArrayBuffer for custom fetch implementations that lack arrayBuffer()
75
+ const text = await response.text();
76
+ const buffer = new TextEncoder().encode(text).buffer;
77
+ return {
78
+ ok: response.ok,
79
+ status: response.status,
80
+ statusText: response.statusText,
81
+ headers: response.headers,
82
+ text: () => Promise.resolve(text),
83
+ json: () => response.json(),
84
+ arrayBuffer: () => Promise.resolve(buffer),
85
+ };
86
+ }
87
+ const response = await fetch(fileUrl, fetchOptions);
88
+ if (!response.ok) {
89
+ throw new Error(`Failed to fetch attachment: ${response.status} ${response.statusText}`);
90
+ }
91
+ return {
92
+ ok: response.ok,
93
+ status: response.status,
94
+ statusText: response.statusText,
95
+ headers: (0, headers_1.headersToRecord)(response.headers),
96
+ text: () => response.text(),
97
+ json: () => response.json(),
98
+ arrayBuffer: () => response.arrayBuffer(),
99
+ };
100
+ }
101
+ }
102
+ exports.UploadClient = UploadClient;
@@ -0,0 +1,367 @@
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.WorkspaceClient = 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 multipart_upload_1 = require("../utils/multipart-upload");
19
+ const request_helpers_1 = require("../utils/request-helpers");
20
+ const validators_1 = require("../utils/validators");
21
+ const base_client_1 = require("./base-client");
22
+ /**
23
+ * Internal sub-client handling all workspace-domain endpoints —
24
+ * workspaces, invitations, users, plans, logos, and workspace project
25
+ * pagination.
26
+ *
27
+ * Instantiated by `TodoistApi`; every public workspace method on
28
+ * `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
29
+ * JSDoc.
30
+ */
31
+ class WorkspaceClient extends base_client_1.BaseClient {
32
+ async getWorkspaceInvitations(args, requestId) {
33
+ const response = await (0, http_client_1.request)({
34
+ httpMethod: 'GET',
35
+ baseUri: this.syncApiBase,
36
+ relativePath: endpoints_1.ENDPOINT_WORKSPACE_INVITATIONS,
37
+ apiToken: this.authToken,
38
+ customFetch: this.customFetch,
39
+ payload: { workspace_id: args.workspaceId },
40
+ requestId: requestId,
41
+ });
42
+ return response.data;
43
+ }
44
+ async getAllWorkspaceInvitations(args = {}, requestId) {
45
+ const queryParams = {};
46
+ if (args.workspaceId) {
47
+ queryParams.workspace_id = args.workspaceId;
48
+ }
49
+ const response = await (0, http_client_1.request)({
50
+ httpMethod: 'GET',
51
+ baseUri: this.syncApiBase,
52
+ relativePath: endpoints_1.ENDPOINT_WORKSPACE_INVITATIONS_ALL,
53
+ apiToken: this.authToken,
54
+ customFetch: this.customFetch,
55
+ payload: queryParams,
56
+ requestId: requestId,
57
+ });
58
+ return (0, validators_1.validateWorkspaceInvitationArray)(response.data);
59
+ }
60
+ async deleteWorkspaceInvitation(args, requestId) {
61
+ const response = await (0, http_client_1.request)({
62
+ httpMethod: 'POST',
63
+ baseUri: this.syncApiBase,
64
+ relativePath: endpoints_1.ENDPOINT_WORKSPACE_INVITATIONS_DELETE,
65
+ apiToken: this.authToken,
66
+ customFetch: this.customFetch,
67
+ payload: {
68
+ workspace_id: args.workspaceId,
69
+ user_email: args.userEmail,
70
+ },
71
+ requestId: requestId,
72
+ });
73
+ return (0, validators_1.validateWorkspaceInvitation)(response.data);
74
+ }
75
+ async acceptWorkspaceInvitation(args, requestId) {
76
+ const response = await (0, http_client_1.request)({
77
+ httpMethod: 'PUT',
78
+ baseUri: this.syncApiBase,
79
+ relativePath: (0, endpoints_1.getWorkspaceInvitationAcceptEndpoint)(args.inviteCode),
80
+ apiToken: this.authToken,
81
+ customFetch: this.customFetch,
82
+ requestId: requestId,
83
+ });
84
+ return (0, validators_1.validateWorkspaceInvitation)(response.data);
85
+ }
86
+ async rejectWorkspaceInvitation(args, requestId) {
87
+ const response = await (0, http_client_1.request)({
88
+ httpMethod: 'PUT',
89
+ baseUri: this.syncApiBase,
90
+ relativePath: (0, endpoints_1.getWorkspaceInvitationRejectEndpoint)(args.inviteCode),
91
+ apiToken: this.authToken,
92
+ customFetch: this.customFetch,
93
+ requestId: requestId,
94
+ });
95
+ return (0, validators_1.validateWorkspaceInvitation)(response.data);
96
+ }
97
+ async joinWorkspace(args, requestId) {
98
+ const response = await (0, http_client_1.request)({
99
+ httpMethod: 'POST',
100
+ baseUri: this.syncApiBase,
101
+ relativePath: endpoints_1.ENDPOINT_WORKSPACE_JOIN,
102
+ apiToken: this.authToken,
103
+ customFetch: this.customFetch,
104
+ payload: {
105
+ invite_code: args.inviteCode,
106
+ workspace_id: args.workspaceId,
107
+ },
108
+ requestId: requestId,
109
+ });
110
+ return (0, validators_1.validateJoinWorkspaceResult)(response.data);
111
+ }
112
+ async uploadWorkspaceLogo(args, requestId) {
113
+ if (args.delete) {
114
+ // Delete logo
115
+ const data = await (0, multipart_upload_1.uploadMultipartFile)({
116
+ baseUrl: this.syncApiBase,
117
+ authToken: this.authToken,
118
+ endpoint: endpoints_1.ENDPOINT_WORKSPACE_LOGO,
119
+ file: Buffer.alloc(0), // Empty buffer for delete
120
+ fileName: 'delete',
121
+ additionalFields: {
122
+ workspace_id: args.workspaceId,
123
+ delete: true,
124
+ },
125
+ requestId: requestId,
126
+ customFetch: this.customFetch,
127
+ });
128
+ return data;
129
+ }
130
+ if (!args.file) {
131
+ throw new Error('file is required when not deleting logo');
132
+ }
133
+ // Validate buffer is not empty if it's a Buffer
134
+ if (Buffer.isBuffer(args.file) && args.file.length === 0) {
135
+ throw new Error('Cannot upload empty image file');
136
+ }
137
+ const additionalFields = {
138
+ workspace_id: args.workspaceId,
139
+ };
140
+ const data = await (0, multipart_upload_1.uploadMultipartFile)({
141
+ baseUrl: this.syncApiBase,
142
+ authToken: this.authToken,
143
+ endpoint: endpoints_1.ENDPOINT_WORKSPACE_LOGO,
144
+ file: args.file,
145
+ fileName: args.fileName,
146
+ additionalFields: additionalFields,
147
+ requestId: requestId,
148
+ customFetch: this.customFetch,
149
+ });
150
+ return data;
151
+ }
152
+ async getWorkspacePlanDetails(args, requestId) {
153
+ const response = await (0, http_client_1.request)({
154
+ httpMethod: 'GET',
155
+ baseUri: this.syncApiBase,
156
+ relativePath: endpoints_1.ENDPOINT_WORKSPACE_PLAN_DETAILS,
157
+ apiToken: this.authToken,
158
+ customFetch: this.customFetch,
159
+ payload: { workspace_id: args.workspaceId },
160
+ requestId: requestId,
161
+ });
162
+ return (0, validators_1.validateWorkspacePlanDetails)(response.data);
163
+ }
164
+ async getWorkspaceUsers(args = {}, requestId) {
165
+ const queryParams = {};
166
+ if (args.workspaceId !== undefined && args.workspaceId !== null) {
167
+ queryParams.workspace_id = args.workspaceId;
168
+ }
169
+ if (args.cursor) {
170
+ queryParams.cursor = args.cursor;
171
+ }
172
+ if (args.limit) {
173
+ queryParams.limit = args.limit;
174
+ }
175
+ const response = await (0, http_client_1.request)({
176
+ httpMethod: 'GET',
177
+ baseUri: this.syncApiBase,
178
+ relativePath: endpoints_1.ENDPOINT_WORKSPACE_USERS,
179
+ apiToken: this.authToken,
180
+ customFetch: this.customFetch,
181
+ payload: queryParams,
182
+ requestId: requestId,
183
+ });
184
+ return {
185
+ hasMore: response.data.hasMore || false,
186
+ nextCursor: response.data.nextCursor,
187
+ workspaceUsers: (0, validators_1.validateWorkspaceUserArray)(response.data.workspaceUsers || []),
188
+ };
189
+ }
190
+ async getWorkspaces(requestId) {
191
+ const response = await (0, http_client_1.request)({
192
+ httpMethod: 'GET',
193
+ baseUri: this.syncApiBase,
194
+ relativePath: endpoints_1.ENDPOINT_REST_WORKSPACES,
195
+ apiToken: this.authToken,
196
+ customFetch: this.customFetch,
197
+ requestId: requestId,
198
+ });
199
+ return (0, validators_1.validateWorkspaceArray)(response.data);
200
+ }
201
+ async getWorkspace(id, requestId) {
202
+ zod_1.z.string().parse(id);
203
+ const response = await (0, http_client_1.request)({
204
+ httpMethod: 'GET',
205
+ baseUri: this.syncApiBase,
206
+ relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_WORKSPACES, id),
207
+ apiToken: this.authToken,
208
+ customFetch: this.customFetch,
209
+ requestId: requestId,
210
+ });
211
+ return (0, validators_1.validateWorkspace)(response.data);
212
+ }
213
+ async addWorkspace(args, requestId) {
214
+ const response = await (0, http_client_1.request)({
215
+ httpMethod: 'POST',
216
+ baseUri: this.syncApiBase,
217
+ relativePath: endpoints_1.ENDPOINT_REST_WORKSPACES,
218
+ apiToken: this.authToken,
219
+ customFetch: this.customFetch,
220
+ payload: args,
221
+ requestId: requestId,
222
+ });
223
+ return (0, validators_1.validateWorkspace)(response.data);
224
+ }
225
+ async updateWorkspace(id, args, requestId) {
226
+ zod_1.z.string().parse(id);
227
+ const response = await (0, http_client_1.request)({
228
+ httpMethod: 'POST',
229
+ baseUri: this.syncApiBase,
230
+ relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_WORKSPACES, id),
231
+ apiToken: this.authToken,
232
+ customFetch: this.customFetch,
233
+ payload: args,
234
+ requestId: requestId,
235
+ });
236
+ return (0, validators_1.validateWorkspace)(response.data);
237
+ }
238
+ async deleteWorkspace(id, requestId) {
239
+ zod_1.z.string().parse(id);
240
+ const response = await (0, http_client_1.request)({
241
+ httpMethod: 'DELETE',
242
+ baseUri: this.syncApiBase,
243
+ relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_WORKSPACES, id),
244
+ apiToken: this.authToken,
245
+ customFetch: this.customFetch,
246
+ requestId: requestId,
247
+ });
248
+ return (0, http_client_1.isSuccess)(response);
249
+ }
250
+ async getWorkspaceMembersActivity(args, requestId) {
251
+ const { workspaceId } = args, queryParams = __rest(args, ["workspaceId"]);
252
+ const { data } = await (0, http_client_1.request)({
253
+ httpMethod: 'GET',
254
+ baseUri: this.syncApiBase,
255
+ relativePath: endpoints_1.ENDPOINT_WORKSPACE_MEMBERS,
256
+ apiToken: this.authToken,
257
+ customFetch: this.customFetch,
258
+ payload: Object.assign({ workspaceId }, queryParams),
259
+ requestId: requestId,
260
+ });
261
+ return {
262
+ members: (0, validators_1.validateMemberActivityInfoArray)(data.members),
263
+ };
264
+ }
265
+ async getWorkspaceUserTasks(args, requestId) {
266
+ const { workspaceId, userId } = args, queryParams = __rest(args, ["workspaceId", "userId"]);
267
+ const { data } = await (0, http_client_1.request)({
268
+ httpMethod: 'GET',
269
+ baseUri: this.syncApiBase,
270
+ relativePath: (0, endpoints_1.getWorkspaceUserTasksEndpoint)(workspaceId, userId),
271
+ apiToken: this.authToken,
272
+ customFetch: this.customFetch,
273
+ payload: queryParams,
274
+ requestId: requestId,
275
+ });
276
+ return {
277
+ tasks: (0, validators_1.validateWorkspaceUserTaskArray)(data.tasks),
278
+ };
279
+ }
280
+ async inviteWorkspaceUsers(args, requestId) {
281
+ const { workspaceId } = args, payload = __rest(args, ["workspaceId"]);
282
+ const { data } = await (0, http_client_1.request)({
283
+ httpMethod: 'POST',
284
+ baseUri: this.syncApiBase,
285
+ relativePath: (0, endpoints_1.getWorkspaceInviteUsersEndpoint)(workspaceId),
286
+ apiToken: this.authToken,
287
+ customFetch: this.customFetch,
288
+ payload: payload,
289
+ requestId: requestId,
290
+ });
291
+ return data;
292
+ }
293
+ async updateWorkspaceUser(args, requestId) {
294
+ const { workspaceId, userId } = args, payload = __rest(args, ["workspaceId", "userId"]);
295
+ const response = await (0, http_client_1.request)({
296
+ httpMethod: 'POST',
297
+ baseUri: this.syncApiBase,
298
+ relativePath: (0, endpoints_1.getWorkspaceUserEndpoint)(workspaceId, userId),
299
+ apiToken: this.authToken,
300
+ customFetch: this.customFetch,
301
+ payload: payload,
302
+ requestId: requestId,
303
+ });
304
+ return (0, validators_1.validateJoinWorkspaceResult)(response.data);
305
+ }
306
+ async removeWorkspaceUser(args, requestId) {
307
+ const { workspaceId, userId } = args;
308
+ const response = await (0, http_client_1.request)({
309
+ httpMethod: 'DELETE',
310
+ baseUri: this.syncApiBase,
311
+ relativePath: (0, endpoints_1.getWorkspaceUserEndpoint)(workspaceId, userId),
312
+ apiToken: this.authToken,
313
+ customFetch: this.customFetch,
314
+ requestId: requestId,
315
+ });
316
+ return (0, http_client_1.isSuccess)(response);
317
+ }
318
+ async getWorkspaceActiveProjects(args, requestId) {
319
+ var _a;
320
+ const queryParams = {};
321
+ if (args.cursor) {
322
+ queryParams.cursor = args.cursor;
323
+ }
324
+ if (args.limit) {
325
+ queryParams.limit = args.limit;
326
+ }
327
+ const response = await (0, http_client_1.request)({
328
+ httpMethod: 'GET',
329
+ baseUri: this.syncApiBase,
330
+ relativePath: (0, endpoints_1.getWorkspaceActiveProjectsEndpoint)(args.workspaceId),
331
+ apiToken: this.authToken,
332
+ customFetch: this.customFetch,
333
+ payload: queryParams,
334
+ requestId: requestId,
335
+ });
336
+ // oxlint-disable-next-line no-unsafe-assignment, no-unsafe-call, no-unsafe-member-access
337
+ const validatedProjects = (_a = response.data.results) === null || _a === void 0 ? void 0 : _a.map((project) => (0, validators_1.validateProject)(project));
338
+ return Object.assign(Object.assign({}, response.data), {
339
+ // oxlint-disable-next-line no-unsafe-assignment
340
+ results: validatedProjects || [] });
341
+ }
342
+ async getWorkspaceArchivedProjects(args, requestId) {
343
+ var _a;
344
+ const queryParams = {};
345
+ if (args.cursor) {
346
+ queryParams.cursor = args.cursor;
347
+ }
348
+ if (args.limit) {
349
+ queryParams.limit = args.limit;
350
+ }
351
+ const response = await (0, http_client_1.request)({
352
+ httpMethod: 'GET',
353
+ baseUri: this.syncApiBase,
354
+ relativePath: (0, endpoints_1.getWorkspaceArchivedProjectsEndpoint)(args.workspaceId),
355
+ apiToken: this.authToken,
356
+ customFetch: this.customFetch,
357
+ payload: queryParams,
358
+ requestId: requestId,
359
+ });
360
+ // oxlint-disable-next-line no-unsafe-assignment, no-unsafe-call, no-unsafe-member-access
361
+ const validatedProjects = (_a = response.data.results) === null || _a === void 0 ? void 0 : _a.map((project) => (0, validators_1.validateProject)(project));
362
+ return Object.assign(Object.assign({}, response.data), {
363
+ // oxlint-disable-next-line no-unsafe-assignment
364
+ results: validatedProjects || [] });
365
+ }
366
+ }
367
+ exports.WorkspaceClient = WorkspaceClient;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ENDPOINT_REST_ID_MAPPINGS = exports.ENDPOINT_REST_EMAILS = exports.ENDPOINT_REST_BACKUPS_DOWNLOAD = exports.ENDPOINT_REST_BACKUPS = exports.ENDPOINT_REST_ACCESS_TOKENS_MIGRATE = exports.ENDPOINT_REST_TEMPLATES_IMPORT_FROM_ID = exports.ENDPOINT_REST_TEMPLATES_IMPORT_FROM_FILE = exports.ENDPOINT_REST_TEMPLATES_CREATE_FROM_FILE = exports.ENDPOINT_REST_TEMPLATES_URL = exports.ENDPOINT_REST_TEMPLATES_FILE = exports.ENDPOINT_REST_TASKS_COMPLETED = exports.ENDPOINT_REST_PROJECTS_MOVE_TO_PERSONAL = exports.ENDPOINT_REST_PROJECTS_MOVE_TO_WORKSPACE = exports.SECTION_UNARCHIVE = exports.SECTION_ARCHIVE = exports.ENDPOINT_REST_PROJECT_JOIN = exports.ENDPOINT_REST_PROJECT_FULL = exports.ENDPOINT_REST_PROJECTS_PERMISSIONS = exports.ENDPOINT_REST_PROJECTS_ARCHIVED_COUNT = exports.PROJECT_UNARCHIVE = exports.PROJECT_ARCHIVE = exports.ENDPOINT_REST_UPLOADS = exports.ENDPOINT_REST_ACTIVITIES = exports.ENDPOINT_REST_PRODUCTIVITY = exports.ENDPOINT_REST_USER = exports.ENDPOINT_REST_PROJECT_COLLABORATORS = exports.ENDPOINT_REST_PROJECTS_ARCHIVED = exports.ENDPOINT_REST_PROJECTS_SEARCH = exports.ENDPOINT_REST_PROJECTS = exports.ENDPOINT_REST_TASK_MOVE = exports.ENDPOINT_REST_TASK_REOPEN = exports.ENDPOINT_REST_TASK_CLOSE = exports.ENDPOINT_REST_LOCATION_REMINDERS = exports.ENDPOINT_REST_REMINDERS = exports.ENDPOINT_REST_COMMENTS = exports.ENDPOINT_REST_LABELS_SHARED_REMOVE = exports.ENDPOINT_REST_LABELS_SHARED_RENAME = exports.ENDPOINT_REST_LABELS_SHARED = exports.ENDPOINT_REST_LABELS_SEARCH = exports.ENDPOINT_REST_LABELS = exports.ENDPOINT_REST_SECTIONS_SEARCH = exports.ENDPOINT_REST_SECTIONS = exports.ENDPOINT_REST_TASKS_COMPLETED_SEARCH = exports.ENDPOINT_REST_TASKS_COMPLETED_BY_DUE_DATE = exports.ENDPOINT_REST_TASKS_COMPLETED_BY_COMPLETION_DATE = exports.ENDPOINT_REST_TASKS_FILTER = exports.ENDPOINT_REST_TASKS = exports.API_BASE_URI = exports.API_VERSION = exports.TODOIST_WEB_URI = void 0;
4
- exports.ENDPOINT_WORKSPACE_MEMBERS = exports.ENDPOINT_WORKSPACE_USERS = exports.ENDPOINT_WORKSPACE_PLAN_DETAILS = exports.ENDPOINT_WORKSPACE_LOGO = exports.ENDPOINT_WORKSPACE_JOIN = exports.ENDPOINT_WORKSPACE_INVITATIONS_DELETE = exports.ENDPOINT_WORKSPACE_INVITATIONS_ALL = exports.ENDPOINT_WORKSPACE_INVITATIONS = exports.ENDPOINT_REST_WORKSPACES = exports.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.ENDPOINT_REST_FOLDERS = exports.ENDPOINT_REGISTER = exports.ENDPOINT_REVOKE = exports.ENDPOINT_GET_TOKEN = exports.ENDPOINT_AUTHORIZATION = exports.ENDPOINT_SYNC = exports.ENDPOINT_SYNC_QUICK_ADD = exports.ENDPOINT_REST_MOVED_IDS = void 0;
5
5
  exports.getSyncBaseUri = getSyncBaseUri;
6
6
  exports.getAuthBaseUri = getAuthBaseUri;
7
7
  exports.getWorkspaceInvitationAcceptEndpoint = getWorkspaceInvitationAcceptEndpoint;
@@ -17,6 +17,20 @@ exports.getWorkspaceInviteUsersEndpoint = getWorkspaceInviteUsersEndpoint;
17
17
  exports.getWorkspaceUserEndpoint = getWorkspaceUserEndpoint;
18
18
  exports.getWorkspaceActiveProjectsEndpoint = getWorkspaceActiveProjectsEndpoint;
19
19
  exports.getWorkspaceArchivedProjectsEndpoint = getWorkspaceArchivedProjectsEndpoint;
20
+ exports.getAppEndpoint = getAppEndpoint;
21
+ exports.getAppSecretsEndpoint = getAppSecretsEndpoint;
22
+ exports.getAppClientSecretEndpoint = getAppClientSecretEndpoint;
23
+ exports.getAppTokensEndpoint = getAppTokensEndpoint;
24
+ exports.getAppTestTokenEndpoint = getAppTestTokenEndpoint;
25
+ exports.getAppDistributionTokenEndpoint = getAppDistributionTokenEndpoint;
26
+ exports.getAppVerificationTokenEndpoint = getAppVerificationTokenEndpoint;
27
+ exports.getAppWebhookEndpoint = getAppWebhookEndpoint;
28
+ exports.getAppIconEndpoint = getAppIconEndpoint;
29
+ exports.getAppInstallationEndpoint = getAppInstallationEndpoint;
30
+ exports.getAppByDistributionTokenEndpoint = getAppByDistributionTokenEndpoint;
31
+ exports.getUiExtensionEndpoint = getUiExtensionEndpoint;
32
+ exports.getUiExtensionIconEndpoint = getUiExtensionIconEndpoint;
33
+ exports.getUiExtensionsByIntegrationEndpoint = getUiExtensionsByIntegrationEndpoint;
20
34
  const BASE_URI = 'https://api.todoist.com';
21
35
  const TODOIST_URI = 'https://todoist.com';
22
36
  exports.TODOIST_WEB_URI = 'https://app.todoist.com/app';
@@ -140,3 +154,54 @@ function getWorkspaceActiveProjectsEndpoint(workspaceId) {
140
154
  function getWorkspaceArchivedProjectsEndpoint(workspaceId) {
141
155
  return `workspaces/${workspaceId}/projects/archived`;
142
156
  }
157
+ // App management endpoints (dev:app_console scope)
158
+ exports.ENDPOINT_REST_APPS = 'apps';
159
+ exports.ENDPOINT_REST_APPS_INSTALLATIONS = 'apps/installations';
160
+ exports.ENDPOINT_REST_APPS_UI_EXTENSIONS = 'apps/ui_extensions';
161
+ exports.ENDPOINT_REST_APPS_UI_EXTENSIONS_INSTALLED = 'apps/ui_extensions/installed';
162
+ exports.ENDPOINT_REST_USER_AUTHORIZATIONS = 'user/authorizations';
163
+ exports.ENDPOINT_REST_USER_AUTHORIZATIONS_DELETE = 'user/authorizations/delete';
164
+ /** Available app icon sizes (small 60x60, medium 300x300, large 600x600). */
165
+ exports.APP_ICON_SIZES = ['small', 'medium', 'large'];
166
+ function getAppEndpoint(appId) {
167
+ return `apps/${appId}`;
168
+ }
169
+ function getAppSecretsEndpoint(appId) {
170
+ return `apps/${appId}/secrets`;
171
+ }
172
+ function getAppClientSecretEndpoint(appId) {
173
+ return `apps/${appId}/client_secret`;
174
+ }
175
+ function getAppTokensEndpoint(appId) {
176
+ return `apps/${appId}/tokens`;
177
+ }
178
+ function getAppTestTokenEndpoint(appId) {
179
+ return `apps/${appId}/test_token`;
180
+ }
181
+ function getAppDistributionTokenEndpoint(appId) {
182
+ return `apps/${appId}/distribution_token`;
183
+ }
184
+ function getAppVerificationTokenEndpoint(appId) {
185
+ return `apps/${appId}/verification_token`;
186
+ }
187
+ function getAppWebhookEndpoint(appId) {
188
+ return `apps/${appId}/webhook`;
189
+ }
190
+ function getAppIconEndpoint(appId, size) {
191
+ return size === 'medium' ? `apps/${appId}/icon` : `apps/${appId}/icon/${size}`;
192
+ }
193
+ function getAppInstallationEndpoint(installationId) {
194
+ return `apps/installations/${installationId}`;
195
+ }
196
+ function getAppByDistributionTokenEndpoint(distributionToken) {
197
+ return `apps/by_distribution_token/${distributionToken}`;
198
+ }
199
+ function getUiExtensionEndpoint(uiExtensionId) {
200
+ return `apps/ui_extensions/${uiExtensionId}`;
201
+ }
202
+ function getUiExtensionIconEndpoint(uiExtensionId) {
203
+ return `apps/ui_extensions/${uiExtensionId}/icon`;
204
+ }
205
+ function getUiExtensionsByIntegrationEndpoint(integrationId) {
206
+ return `apps/ui_extensions/integration/${integrationId}`;
207
+ }