@doist/todoist-api-typescript 7.9.1 → 7.10.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.
- package/README.md +5 -204
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.mjs +1 -0
- package/package.json +12 -92
- package/LICENSE +0 -21
- package/dist/cjs/authentication.js +0 -204
- package/dist/cjs/consts/endpoints.js +0 -141
- package/dist/cjs/index.js +0 -20
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/test-utils/asserts.js +0 -11
- package/dist/cjs/test-utils/msw-setup.js +0 -97
- package/dist/cjs/test-utils/obsidian-fetch-adapter.js +0 -53
- package/dist/cjs/test-utils/test-defaults.js +0 -240
- package/dist/cjs/todoist-api.js +0 -2623
- package/dist/cjs/transport/fetch-with-retry.js +0 -206
- package/dist/cjs/transport/http-client.js +0 -133
- package/dist/cjs/transport/http-dispatcher.js +0 -72
- package/dist/cjs/types/activity/index.js +0 -18
- package/dist/cjs/types/activity/requests.js +0 -2
- package/dist/cjs/types/activity/types.js +0 -28
- package/dist/cjs/types/backups/index.js +0 -18
- package/dist/cjs/types/backups/requests.js +0 -2
- package/dist/cjs/types/backups/types.js +0 -8
- package/dist/cjs/types/comments/index.js +0 -18
- package/dist/cjs/types/comments/requests.js +0 -2
- package/dist/cjs/types/comments/types.js +0 -60
- package/dist/cjs/types/common.js +0 -10
- package/dist/cjs/types/emails/index.js +0 -17
- package/dist/cjs/types/emails/requests.js +0 -5
- package/dist/cjs/types/errors.js +0 -29
- package/dist/cjs/types/folders/index.js +0 -17
- package/dist/cjs/types/folders/requests.js +0 -2
- package/dist/cjs/types/http.js +0 -24
- package/dist/cjs/types/id-mappings/index.js +0 -18
- package/dist/cjs/types/id-mappings/requests.js +0 -20
- package/dist/cjs/types/id-mappings/types.js +0 -12
- package/dist/cjs/types/index.js +0 -36
- package/dist/cjs/types/insights/index.js +0 -18
- package/dist/cjs/types/insights/requests.js +0 -2
- package/dist/cjs/types/insights/types.js +0 -84
- package/dist/cjs/types/labels/index.js +0 -18
- package/dist/cjs/types/labels/requests.js +0 -2
- package/dist/cjs/types/labels/types.js +0 -11
- package/dist/cjs/types/productivity/index.js +0 -17
- package/dist/cjs/types/productivity/types.js +0 -67
- package/dist/cjs/types/projects/index.js +0 -18
- package/dist/cjs/types/projects/requests.js +0 -2
- package/dist/cjs/types/projects/types.js +0 -56
- package/dist/cjs/types/reminders/index.js +0 -17
- package/dist/cjs/types/reminders/requests.js +0 -95
- package/dist/cjs/types/sections/index.js +0 -18
- package/dist/cjs/types/sections/requests.js +0 -2
- package/dist/cjs/types/sections/types.js +0 -22
- package/dist/cjs/types/sync/commands/calendars.js +0 -2
- package/dist/cjs/types/sync/commands/filters.js +0 -2
- package/dist/cjs/types/sync/commands/folders.js +0 -2
- package/dist/cjs/types/sync/commands/index.js +0 -35
- package/dist/cjs/types/sync/commands/labels.js +0 -5
- package/dist/cjs/types/sync/commands/notes.js +0 -2
- package/dist/cjs/types/sync/commands/notifications.js +0 -2
- package/dist/cjs/types/sync/commands/others.js +0 -2
- package/dist/cjs/types/sync/commands/project-view-options.js +0 -2
- package/dist/cjs/types/sync/commands/projects.js +0 -2
- package/dist/cjs/types/sync/commands/reminders.js +0 -2
- package/dist/cjs/types/sync/commands/sections.js +0 -2
- package/dist/cjs/types/sync/commands/shared.js +0 -20
- package/dist/cjs/types/sync/commands/sharing.js +0 -2
- package/dist/cjs/types/sync/commands/tasks.js +0 -2
- package/dist/cjs/types/sync/commands/view-options.js +0 -2
- package/dist/cjs/types/sync/commands/workspace-filters.js +0 -2
- package/dist/cjs/types/sync/commands/workspace-goals.js +0 -2
- package/dist/cjs/types/sync/commands/workspaces.js +0 -2
- package/dist/cjs/types/sync/index.js +0 -22
- package/dist/cjs/types/sync/request.js +0 -2
- package/dist/cjs/types/sync/resource-types.js +0 -40
- package/dist/cjs/types/sync/resources/calendars.js +0 -31
- package/dist/cjs/types/sync/resources/collaborators.js +0 -25
- package/dist/cjs/types/sync/resources/completed-info.js +0 -30
- package/dist/cjs/types/sync/resources/filters.js +0 -16
- package/dist/cjs/types/sync/resources/folders.js +0 -14
- package/dist/cjs/types/sync/resources/index.js +0 -33
- package/dist/cjs/types/sync/resources/live-notifications.js +0 -39
- package/dist/cjs/types/sync/resources/notes.js +0 -23
- package/dist/cjs/types/sync/resources/reminders.js +0 -50
- package/dist/cjs/types/sync/resources/suggestions.js +0 -42
- package/dist/cjs/types/sync/resources/tooltips.js +0 -10
- package/dist/cjs/types/sync/resources/user-plan-limits.js +0 -24
- package/dist/cjs/types/sync/resources/user-settings.js +0 -42
- package/dist/cjs/types/sync/resources/user.js +0 -120
- package/dist/cjs/types/sync/resources/view-options.js +0 -83
- package/dist/cjs/types/sync/resources/workspace-filters.js +0 -21
- package/dist/cjs/types/sync/resources/workspace-goals.js +0 -32
- package/dist/cjs/types/sync/resources/workspaces.js +0 -73
- package/dist/cjs/types/sync/response.js +0 -2
- package/dist/cjs/types/sync/user-preferences.js +0 -71
- package/dist/cjs/types/tasks/index.js +0 -18
- package/dist/cjs/types/tasks/requests.js +0 -2
- package/dist/cjs/types/tasks/types.js +0 -59
- package/dist/cjs/types/templates/index.js +0 -17
- package/dist/cjs/types/templates/requests.js +0 -2
- package/dist/cjs/types/uploads/index.js +0 -17
- package/dist/cjs/types/uploads/requests.js +0 -2
- package/dist/cjs/types/users/index.js +0 -17
- package/dist/cjs/types/users/types.js +0 -51
- package/dist/cjs/types/workspaces/index.js +0 -18
- package/dist/cjs/types/workspaces/requests.js +0 -2
- package/dist/cjs/types/workspaces/types.js +0 -155
- package/dist/cjs/utils/activity-helpers.js +0 -58
- package/dist/cjs/utils/case-conversion.js +0 -69
- package/dist/cjs/utils/colors.js +0 -143
- package/dist/cjs/utils/index.js +0 -25
- package/dist/cjs/utils/multipart-upload.js +0 -178
- package/dist/cjs/utils/processing-helpers.js +0 -18
- package/dist/cjs/utils/sanitization.js +0 -116
- package/dist/cjs/utils/sync-helpers.js +0 -22
- package/dist/cjs/utils/uncompletable-helpers.js +0 -60
- package/dist/cjs/utils/url-helpers.js +0 -74
- package/dist/cjs/utils/validators.js +0 -141
- package/dist/esm/authentication.js +0 -196
- package/dist/esm/consts/endpoints.js +0 -122
- package/dist/esm/index.js +0 -4
- package/dist/esm/test-utils/asserts.js +0 -8
- package/dist/esm/test-utils/msw-setup.js +0 -88
- package/dist/esm/test-utils/obsidian-fetch-adapter.js +0 -50
- package/dist/esm/test-utils/test-defaults.js +0 -237
- package/dist/esm/todoist-api.js +0 -2619
- package/dist/esm/transport/fetch-with-retry.js +0 -203
- package/dist/esm/transport/http-client.js +0 -128
- package/dist/esm/transport/http-dispatcher.js +0 -35
- package/dist/esm/types/activity/index.js +0 -2
- package/dist/esm/types/activity/requests.js +0 -1
- package/dist/esm/types/activity/types.js +0 -25
- package/dist/esm/types/backups/index.js +0 -2
- package/dist/esm/types/backups/requests.js +0 -1
- package/dist/esm/types/backups/types.js +0 -5
- package/dist/esm/types/comments/index.js +0 -2
- package/dist/esm/types/comments/requests.js +0 -1
- package/dist/esm/types/comments/types.js +0 -57
- package/dist/esm/types/common.js +0 -7
- package/dist/esm/types/emails/index.js +0 -1
- package/dist/esm/types/emails/requests.js +0 -2
- package/dist/esm/types/errors.js +0 -24
- package/dist/esm/types/folders/index.js +0 -1
- package/dist/esm/types/folders/requests.js +0 -1
- package/dist/esm/types/http.js +0 -20
- package/dist/esm/types/id-mappings/index.js +0 -2
- package/dist/esm/types/id-mappings/requests.js +0 -17
- package/dist/esm/types/id-mappings/types.js +0 -9
- package/dist/esm/types/index.js +0 -20
- package/dist/esm/types/insights/index.js +0 -2
- package/dist/esm/types/insights/requests.js +0 -1
- package/dist/esm/types/insights/types.js +0 -81
- package/dist/esm/types/labels/index.js +0 -2
- package/dist/esm/types/labels/requests.js +0 -1
- package/dist/esm/types/labels/types.js +0 -8
- package/dist/esm/types/productivity/index.js +0 -1
- package/dist/esm/types/productivity/types.js +0 -64
- package/dist/esm/types/projects/index.js +0 -2
- package/dist/esm/types/projects/requests.js +0 -1
- package/dist/esm/types/projects/types.js +0 -53
- package/dist/esm/types/reminders/index.js +0 -1
- package/dist/esm/types/reminders/requests.js +0 -92
- package/dist/esm/types/sections/index.js +0 -2
- package/dist/esm/types/sections/requests.js +0 -1
- package/dist/esm/types/sections/types.js +0 -19
- package/dist/esm/types/sync/commands/calendars.js +0 -1
- package/dist/esm/types/sync/commands/filters.js +0 -1
- package/dist/esm/types/sync/commands/folders.js +0 -1
- package/dist/esm/types/sync/commands/index.js +0 -19
- package/dist/esm/types/sync/commands/labels.js +0 -2
- package/dist/esm/types/sync/commands/notes.js +0 -1
- package/dist/esm/types/sync/commands/notifications.js +0 -1
- package/dist/esm/types/sync/commands/others.js +0 -1
- package/dist/esm/types/sync/commands/project-view-options.js +0 -1
- package/dist/esm/types/sync/commands/projects.js +0 -1
- package/dist/esm/types/sync/commands/reminders.js +0 -1
- package/dist/esm/types/sync/commands/sections.js +0 -1
- package/dist/esm/types/sync/commands/shared.js +0 -16
- package/dist/esm/types/sync/commands/sharing.js +0 -1
- package/dist/esm/types/sync/commands/tasks.js +0 -1
- package/dist/esm/types/sync/commands/view-options.js +0 -1
- package/dist/esm/types/sync/commands/workspace-filters.js +0 -1
- package/dist/esm/types/sync/commands/workspace-goals.js +0 -1
- package/dist/esm/types/sync/commands/workspaces.js +0 -1
- package/dist/esm/types/sync/index.js +0 -6
- package/dist/esm/types/sync/request.js +0 -1
- package/dist/esm/types/sync/resource-types.js +0 -37
- package/dist/esm/types/sync/resources/calendars.js +0 -28
- package/dist/esm/types/sync/resources/collaborators.js +0 -22
- package/dist/esm/types/sync/resources/completed-info.js +0 -27
- package/dist/esm/types/sync/resources/filters.js +0 -13
- package/dist/esm/types/sync/resources/folders.js +0 -11
- package/dist/esm/types/sync/resources/index.js +0 -17
- package/dist/esm/types/sync/resources/live-notifications.js +0 -36
- package/dist/esm/types/sync/resources/notes.js +0 -20
- package/dist/esm/types/sync/resources/reminders.js +0 -47
- package/dist/esm/types/sync/resources/suggestions.js +0 -39
- package/dist/esm/types/sync/resources/tooltips.js +0 -7
- package/dist/esm/types/sync/resources/user-plan-limits.js +0 -21
- package/dist/esm/types/sync/resources/user-settings.js +0 -39
- package/dist/esm/types/sync/resources/user.js +0 -117
- package/dist/esm/types/sync/resources/view-options.js +0 -80
- package/dist/esm/types/sync/resources/workspace-filters.js +0 -18
- package/dist/esm/types/sync/resources/workspace-goals.js +0 -29
- package/dist/esm/types/sync/resources/workspaces.js +0 -70
- package/dist/esm/types/sync/response.js +0 -1
- package/dist/esm/types/sync/user-preferences.js +0 -68
- package/dist/esm/types/tasks/index.js +0 -2
- package/dist/esm/types/tasks/requests.js +0 -1
- package/dist/esm/types/tasks/types.js +0 -56
- package/dist/esm/types/templates/index.js +0 -1
- package/dist/esm/types/templates/requests.js +0 -1
- package/dist/esm/types/uploads/index.js +0 -1
- package/dist/esm/types/uploads/requests.js +0 -1
- package/dist/esm/types/users/index.js +0 -1
- package/dist/esm/types/users/types.js +0 -48
- package/dist/esm/types/workspaces/index.js +0 -2
- package/dist/esm/types/workspaces/requests.js +0 -1
- package/dist/esm/types/workspaces/types.js +0 -152
- package/dist/esm/utils/activity-helpers.js +0 -53
- package/dist/esm/utils/case-conversion.js +0 -61
- package/dist/esm/utils/colors.js +0 -139
- package/dist/esm/utils/index.js +0 -4
- package/dist/esm/utils/multipart-upload.js +0 -142
- package/dist/esm/utils/processing-helpers.js +0 -12
- package/dist/esm/utils/sanitization.js +0 -112
- package/dist/esm/utils/sync-helpers.js +0 -19
- package/dist/esm/utils/uncompletable-helpers.js +0 -54
- package/dist/esm/utils/url-helpers.js +0 -68
- package/dist/esm/utils/validators.js +0 -132
- package/dist/types/authentication.d.ts +0 -158
- package/dist/types/consts/endpoints.d.ts +0 -81
- package/dist/types/index.d.ts +0 -4
- package/dist/types/test-utils/asserts.d.ts +0 -1
- package/dist/types/test-utils/msw-setup.d.ts +0 -33
- package/dist/types/test-utils/obsidian-fetch-adapter.d.ts +0 -29
- package/dist/types/test-utils/test-defaults.d.ts +0 -261
- package/dist/types/todoist-api.d.ts +0 -1018
- package/dist/types/transport/fetch-with-retry.d.ts +0 -12
- package/dist/types/transport/http-client.d.ts +0 -16
- package/dist/types/transport/http-dispatcher.d.ts +0 -3
- package/dist/types/types/activity/index.d.ts +0 -2
- package/dist/types/types/activity/requests.d.ts +0 -85
- package/dist/types/types/activity/types.d.ts +0 -49
- package/dist/types/types/backups/index.d.ts +0 -2
- package/dist/types/types/backups/requests.d.ts +0 -16
- package/dist/types/types/backups/types.d.ts +0 -7
- package/dist/types/types/comments/index.d.ts +0 -2
- package/dist/types/types/comments/requests.d.ts +0 -64
- package/dist/types/types/comments/types.d.ts +0 -141
- package/dist/types/types/common.d.ts +0 -13
- package/dist/types/types/emails/index.d.ts +0 -1
- package/dist/types/types/emails/requests.d.ts +0 -30
- package/dist/types/types/errors.d.ts +0 -12
- package/dist/types/types/folders/index.d.ts +0 -1
- package/dist/types/types/folders/requests.d.ts +0 -20
- package/dist/types/types/http.d.ts +0 -85
- package/dist/types/types/id-mappings/index.d.ts +0 -2
- package/dist/types/types/id-mappings/requests.d.ts +0 -28
- package/dist/types/types/id-mappings/types.d.ts +0 -13
- package/dist/types/types/index.d.ts +0 -20
- package/dist/types/types/insights/index.d.ts +0 -2
- package/dist/types/types/insights/requests.d.ts +0 -26
- package/dist/types/types/insights/types.d.ts +0 -186
- package/dist/types/types/labels/index.d.ts +0 -2
- package/dist/types/types/labels/requests.d.ts +0 -75
- package/dist/types/types/labels/types.d.ts +0 -13
- package/dist/types/types/productivity/index.d.ts +0 -1
- package/dist/types/types/productivity/types.d.ts +0 -115
- package/dist/types/types/projects/index.d.ts +0 -2
- package/dist/types/types/projects/requests.d.ts +0 -169
- package/dist/types/types/projects/types.d.ts +0 -201
- package/dist/types/types/reminders/index.d.ts +0 -1
- package/dist/types/types/reminders/requests.d.ts +0 -205
- package/dist/types/types/sections/index.d.ts +0 -2
- package/dist/types/types/sections/requests.d.ts +0 -41
- package/dist/types/types/sections/types.d.ts +0 -44
- package/dist/types/types/sync/commands/calendars.d.ts +0 -14
- package/dist/types/types/sync/commands/filters.d.ts +0 -22
- package/dist/types/types/sync/commands/folders.d.ts +0 -18
- package/dist/types/types/sync/commands/index.d.ts +0 -171
- package/dist/types/types/sync/commands/labels.d.ts +0 -32
- package/dist/types/types/sync/commands/notes.d.ts +0 -27
- package/dist/types/types/sync/commands/notifications.d.ts +0 -10
- package/dist/types/types/sync/commands/others.d.ts +0 -39
- package/dist/types/types/sync/commands/project-view-options.d.ts +0 -14
- package/dist/types/types/sync/commands/projects.d.ts +0 -90
- package/dist/types/types/sync/commands/reminders.d.ts +0 -51
- package/dist/types/types/sync/commands/sections.d.ts +0 -31
- package/dist/types/types/sync/commands/shared.d.ts +0 -51
- package/dist/types/types/sync/commands/sharing.d.ts +0 -16
- package/dist/types/types/sync/commands/tasks.d.ts +0 -78
- package/dist/types/types/sync/commands/view-options.d.ts +0 -15
- package/dist/types/types/sync/commands/workspace-filters.d.ts +0 -23
- package/dist/types/types/sync/commands/workspace-goals.d.ts +0 -24
- package/dist/types/types/sync/commands/workspaces.d.ts +0 -79
- package/dist/types/types/sync/index.d.ts +0 -6
- package/dist/types/types/sync/request.d.ts +0 -7
- package/dist/types/types/sync/resource-types.d.ts +0 -5
- package/dist/types/types/sync/resources/calendars.d.ts +0 -38
- package/dist/types/types/sync/resources/collaborators.d.ts +0 -28
- package/dist/types/types/sync/resources/completed-info.d.ts +0 -33
- package/dist/types/types/sync/resources/filters.d.ts +0 -12
- package/dist/types/types/sync/resources/folders.d.ts +0 -10
- package/dist/types/types/sync/resources/index.d.ts +0 -17
- package/dist/types/types/sync/resources/live-notifications.d.ts +0 -32
- package/dist/types/types/sync/resources/notes.d.ts +0 -34
- package/dist/types/types/sync/resources/reminders.d.ts +0 -126
- package/dist/types/types/sync/resources/suggestions.d.ts +0 -96
- package/dist/types/types/sync/resources/tooltips.d.ts +0 -6
- package/dist/types/types/sync/resources/user-plan-limits.d.ts +0 -41
- package/dist/types/types/sync/resources/user-settings.d.ts +0 -40
- package/dist/types/types/sync/resources/user.d.ts +0 -134
- package/dist/types/types/sync/resources/view-options.d.ts +0 -169
- package/dist/types/types/sync/resources/workspace-filters.d.ts +0 -17
- package/dist/types/types/sync/resources/workspace-goals.d.ts +0 -29
- package/dist/types/types/sync/resources/workspaces.d.ts +0 -142
- package/dist/types/types/sync/response.d.ts +0 -51
- package/dist/types/types/sync/user-preferences.d.ts +0 -39
- package/dist/types/types/tasks/index.d.ts +0 -2
- package/dist/types/types/tasks/requests.d.ts +0 -197
- package/dist/types/types/tasks/types.d.ts +0 -162
- package/dist/types/types/templates/index.d.ts +0 -1
- package/dist/types/types/templates/requests.d.ts +0 -92
- package/dist/types/types/uploads/index.d.ts +0 -1
- package/dist/types/types/uploads/requests.d.ts +0 -32
- package/dist/types/types/users/index.d.ts +0 -1
- package/dist/types/types/users/types.d.ts +0 -66
- package/dist/types/types/workspaces/index.d.ts +0 -2
- package/dist/types/types/workspaces/requests.d.ts +0 -260
- package/dist/types/types/workspaces/types.d.ts +0 -267
- package/dist/types/utils/activity-helpers.d.ts +0 -28
- package/dist/types/utils/case-conversion.d.ts +0 -12
- package/dist/types/utils/colors.d.ts +0 -197
- package/dist/types/utils/index.d.ts +0 -4
- package/dist/types/utils/multipart-upload.d.ts +0 -54
- package/dist/types/utils/processing-helpers.d.ts +0 -1
- package/dist/types/utils/sanitization.d.ts +0 -35
- package/dist/types/utils/sync-helpers.d.ts +0 -17
- package/dist/types/utils/uncompletable-helpers.d.ts +0 -30
- package/dist/types/utils/url-helpers.d.ts +0 -32
- package/dist/types/utils/validators.d.ts +0 -1404
package/dist/esm/todoist-api.js
DELETED
|
@@ -1,2619 +0,0 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import { UpdateReminderArgsSchema, UpdateLocationReminderArgsSchema, ReminderIdSchema, } from './types/reminders/index.js';
|
|
13
|
-
import { request, isSuccess } from './transport/http-client.js';
|
|
14
|
-
import { getSyncBaseUri, ENDPOINT_REST_TASKS, ENDPOINT_REST_TASKS_FILTER, ENDPOINT_REST_TASKS_COMPLETED_BY_COMPLETION_DATE, ENDPOINT_REST_TASKS_COMPLETED_BY_DUE_DATE, ENDPOINT_REST_TASKS_COMPLETED_SEARCH, ENDPOINT_REST_TASKS_COMPLETED, ENDPOINT_REST_TEMPLATES_FILE, ENDPOINT_REST_TEMPLATES_URL, ENDPOINT_REST_TEMPLATES_CREATE_FROM_FILE, ENDPOINT_REST_TEMPLATES_IMPORT_FROM_FILE, ENDPOINT_REST_TEMPLATES_IMPORT_FROM_ID, ENDPOINT_REST_PROJECTS, ENDPOINT_REST_PROJECTS_SEARCH, ENDPOINT_SYNC_QUICK_ADD, ENDPOINT_REST_TASK_CLOSE, ENDPOINT_REST_TASK_REOPEN, ENDPOINT_REST_TASK_MOVE, ENDPOINT_REST_LABELS, ENDPOINT_REST_LABELS_SEARCH, ENDPOINT_REST_PROJECT_COLLABORATORS, ENDPOINT_REST_SECTIONS, ENDPOINT_REST_SECTIONS_SEARCH, ENDPOINT_REST_COMMENTS, ENDPOINT_REST_LOCATION_REMINDERS, ENDPOINT_REST_REMINDERS, ENDPOINT_REST_LABELS_SHARED, ENDPOINT_REST_LABELS_SHARED_RENAME, ENDPOINT_REST_LABELS_SHARED_REMOVE, ENDPOINT_SYNC, PROJECT_ARCHIVE, PROJECT_UNARCHIVE, ENDPOINT_REST_PROJECTS_MOVE_TO_WORKSPACE, ENDPOINT_REST_PROJECTS_MOVE_TO_PERSONAL, ENDPOINT_REST_PROJECTS_ARCHIVED, ENDPOINT_REST_PROJECTS_ARCHIVED_COUNT, ENDPOINT_REST_PROJECTS_PERMISSIONS, ENDPOINT_REST_PROJECT_FULL, ENDPOINT_REST_PROJECT_JOIN, SECTION_ARCHIVE, SECTION_UNARCHIVE, ENDPOINT_REST_USER, ENDPOINT_REST_PRODUCTIVITY, ENDPOINT_REST_ACTIVITIES, ENDPOINT_REST_UPLOADS, getProjectInsightsActivityStatsEndpoint, getProjectInsightsHealthEndpoint, getProjectInsightsHealthContextEndpoint, getProjectInsightsProgressEndpoint, getProjectInsightsHealthAnalyzeEndpoint, getWorkspaceInsightsEndpoint, ENDPOINT_REST_BACKUPS, ENDPOINT_REST_BACKUPS_DOWNLOAD, ENDPOINT_REST_EMAILS, ENDPOINT_REST_ID_MAPPINGS, ENDPOINT_REST_MOVED_IDS, ENDPOINT_REST_WORKSPACES, ENDPOINT_WORKSPACE_MEMBERS, getWorkspaceUserTasksEndpoint, getWorkspaceInviteUsersEndpoint, getWorkspaceUserEndpoint, ENDPOINT_WORKSPACE_INVITATIONS, ENDPOINT_WORKSPACE_INVITATIONS_ALL, ENDPOINT_WORKSPACE_INVITATIONS_DELETE, getWorkspaceInvitationAcceptEndpoint, getWorkspaceInvitationRejectEndpoint, ENDPOINT_WORKSPACE_JOIN, ENDPOINT_WORKSPACE_LOGO, ENDPOINT_WORKSPACE_PLAN_DETAILS, ENDPOINT_WORKSPACE_USERS, getWorkspaceActiveProjectsEndpoint, getWorkspaceArchivedProjectsEndpoint, ENDPOINT_REST_FOLDERS, } from './consts/endpoints.js';
|
|
15
|
-
import { validateAttachment, validateComment, validateCommentArray, validateCurrentUser, validateLabel, validateLabelArray, validateProject, validateProjectArray, validateSection, validateSectionArray, validateTask, validateTaskArray, validateUserArray, validateProductivityStats, validateReminder, validateReminderArray, validateLocationReminderArray, validateActivityEventArray, validateWorkspaceUserArray, validateWorkspaceInvitation, validateWorkspaceInvitationArray, validateWorkspacePlanDetails, validateJoinWorkspaceResult, validateWorkspace, validateWorkspaceArray, validateMemberActivityInfoArray, validateWorkspaceUserTaskArray, validateProjectActivityStats, validateProjectHealth, validateProjectHealthContext, validateProjectProgress, validateWorkspaceInsights, validateBackupArray, validateIdMappingArray, validateMovedIdArray, validateFolder, validateFolderArray, } from './utils/validators.js';
|
|
16
|
-
import { formatDateToYYYYMMDD } from './utils/url-helpers.js';
|
|
17
|
-
import { uploadMultipartFile } from './utils/multipart-upload.js';
|
|
18
|
-
import { camelCaseKeys } from './utils/case-conversion.js';
|
|
19
|
-
import { normalizeObjectEventTypeForApi, denormalizeObjectTypeFromApi, } from './utils/activity-helpers.js';
|
|
20
|
-
import { processTaskContent } from './utils/uncompletable-helpers.js';
|
|
21
|
-
import { z } from 'zod';
|
|
22
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
23
|
-
import { DATE_FORMAT_TO_API, TIME_FORMAT_TO_API, DAY_OF_WEEK_TO_API, } from './types/sync/index.js';
|
|
24
|
-
import { TodoistArgumentError, TodoistRequestError } from './types/index.js';
|
|
25
|
-
const MAX_COMMAND_COUNT = 100;
|
|
26
|
-
/**
|
|
27
|
-
* Joins path segments using `/` separator.
|
|
28
|
-
* @param segments A list of **valid** path segments.
|
|
29
|
-
* @returns A joined path.
|
|
30
|
-
*/
|
|
31
|
-
function generatePath(...segments) {
|
|
32
|
-
return segments.join('/');
|
|
33
|
-
}
|
|
34
|
-
function spreadIfDefined(value, fn) {
|
|
35
|
-
return value !== undefined ? fn(value) : {};
|
|
36
|
-
}
|
|
37
|
-
function serializeUserUpdateArgs(args) {
|
|
38
|
-
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, args), spreadIfDefined(args.dateFormat, (v) => ({ dateFormat: DATE_FORMAT_TO_API[v] }))), spreadIfDefined(args.timeFormat, (v) => ({ timeFormat: TIME_FORMAT_TO_API[v] }))), spreadIfDefined(args.startDay, (v) => ({ startDay: DAY_OF_WEEK_TO_API[v] }))), spreadIfDefined(args.nextWeek, (v) => ({ nextWeek: DAY_OF_WEEK_TO_API[v] })));
|
|
39
|
-
}
|
|
40
|
-
function serializeTaskUpdateDateCompleteArgs(args) {
|
|
41
|
-
return Object.assign(Object.assign(Object.assign({}, args), { isForward: args.isForward ? 1 : 0 }), spreadIfDefined(args.resetSubtasks, (v) => ({ resetSubtasks: v ? 1 : 0 })));
|
|
42
|
-
}
|
|
43
|
-
function serializeUpdateGoalsArgs(args) {
|
|
44
|
-
return Object.assign(Object.assign(Object.assign({}, args), spreadIfDefined(args.vacationMode, (v) => ({ vacationMode: v ? 1 : 0 }))), spreadIfDefined(args.karmaDisabled, (v) => ({ karmaDisabled: v ? 1 : 0 })));
|
|
45
|
-
}
|
|
46
|
-
function preprocessSyncCommands(commands) {
|
|
47
|
-
return commands.map((cmd) => {
|
|
48
|
-
if (cmd.type === 'user_update')
|
|
49
|
-
return Object.assign(Object.assign({}, cmd), { args: serializeUserUpdateArgs(cmd.args) });
|
|
50
|
-
if (cmd.type === 'item_update_date_complete')
|
|
51
|
-
return Object.assign(Object.assign({}, cmd), { args: serializeTaskUpdateDateCompleteArgs(cmd.args) });
|
|
52
|
-
if (cmd.type === 'update_goals')
|
|
53
|
-
return Object.assign(Object.assign({}, cmd), { args: serializeUpdateGoalsArgs(cmd.args) });
|
|
54
|
-
return cmd;
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* A client for interacting with the Todoist API v1.
|
|
59
|
-
* This class provides methods to manage tasks, projects, sections, labels, and comments in Todoist.
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
62
|
-
* ```typescript
|
|
63
|
-
* const api = new TodoistApi('your-api-token');
|
|
64
|
-
*
|
|
65
|
-
* // Get all tasks
|
|
66
|
-
* const tasks = await api.getTasks();
|
|
67
|
-
*
|
|
68
|
-
* // Create a new task
|
|
69
|
-
* const newTask = await api.addTask({
|
|
70
|
-
* content: 'My new task',
|
|
71
|
-
* projectId: '12345'
|
|
72
|
-
* });
|
|
73
|
-
* ```
|
|
74
|
-
*
|
|
75
|
-
* For more information about the Todoist API v1, see the [official documentation](https://todoist.com/api/v1).
|
|
76
|
-
* If you're migrating from v9, please refer to the [migration guide](https://todoist.com/api/v1/docs#tag/Migrating-from-v9).
|
|
77
|
-
*/
|
|
78
|
-
function headersToRecord(headers) {
|
|
79
|
-
const result = {};
|
|
80
|
-
headers.forEach((value, key) => {
|
|
81
|
-
result[key] = value;
|
|
82
|
-
});
|
|
83
|
-
return result;
|
|
84
|
-
}
|
|
85
|
-
export class TodoistApi {
|
|
86
|
-
constructor(
|
|
87
|
-
/**
|
|
88
|
-
* Your Todoist API token.
|
|
89
|
-
*/
|
|
90
|
-
authToken,
|
|
91
|
-
/**
|
|
92
|
-
* Optional configuration options
|
|
93
|
-
*/
|
|
94
|
-
options) {
|
|
95
|
-
if (typeof options === 'string') {
|
|
96
|
-
throw new TypeError('Passing baseUrl as a string is no longer supported. Use an options object instead: new TodoistApi(token, { baseUrl })');
|
|
97
|
-
}
|
|
98
|
-
this.authToken = authToken;
|
|
99
|
-
const opts = options || {};
|
|
100
|
-
this.syncApiBase = getSyncBaseUri(opts.baseUrl);
|
|
101
|
-
this.customFetch = opts.customFetch;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Makes a request to the Sync API and handles error checking.
|
|
105
|
-
*
|
|
106
|
-
* @param syncRequest - The sync request payload
|
|
107
|
-
* @param requestId - Optional request identifier
|
|
108
|
-
* @param hasSyncCommands - Whether this request contains sync commands (write operations)
|
|
109
|
-
* @returns The sync response data
|
|
110
|
-
* @throws TodoistRequestError if sync status contains errors
|
|
111
|
-
*/
|
|
112
|
-
async requestSync(syncRequest, requestId, hasSyncCommands = false) {
|
|
113
|
-
var _a;
|
|
114
|
-
const processedRequest = ((_a = syncRequest.commands) === null || _a === void 0 ? void 0 : _a.length)
|
|
115
|
-
? Object.assign(Object.assign({}, syncRequest), { commands: preprocessSyncCommands(syncRequest.commands) }) : syncRequest;
|
|
116
|
-
const response = await request({
|
|
117
|
-
httpMethod: 'POST',
|
|
118
|
-
baseUri: this.syncApiBase,
|
|
119
|
-
relativePath: ENDPOINT_SYNC,
|
|
120
|
-
apiToken: this.authToken,
|
|
121
|
-
customFetch: this.customFetch,
|
|
122
|
-
payload: processedRequest,
|
|
123
|
-
requestId: requestId,
|
|
124
|
-
hasSyncCommands: hasSyncCommands,
|
|
125
|
-
});
|
|
126
|
-
// Check for sync errors and throw if any are found
|
|
127
|
-
if (response.data.syncStatus) {
|
|
128
|
-
Object.entries(response.data.syncStatus).forEach(([_, value]) => {
|
|
129
|
-
if (value === 'ok')
|
|
130
|
-
return;
|
|
131
|
-
throw new TodoistRequestError(value.error, value.httpCode, value.errorExtra);
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
return response.data;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Executes a raw Sync API request.
|
|
138
|
-
*
|
|
139
|
-
* This method provides direct access to the Sync API, allowing you to send
|
|
140
|
-
* strongly-typed commands and request specific resource types.
|
|
141
|
-
*
|
|
142
|
-
* @param request - The sync request payload containing commands and/or resource types.
|
|
143
|
-
* @param requestId - Optional custom identifier for the request.
|
|
144
|
-
* @returns A promise that resolves to the sync response.
|
|
145
|
-
* @throws TodoistRequestError if the sync status contains errors.
|
|
146
|
-
*
|
|
147
|
-
* @example
|
|
148
|
-
* ```typescript
|
|
149
|
-
* import { createCommand } from '@doist/todoist-api-typescript'
|
|
150
|
-
*
|
|
151
|
-
* const response = await api.sync({
|
|
152
|
-
* commands: [
|
|
153
|
-
* createCommand('item_add', { content: 'Buy milk' }),
|
|
154
|
-
* ],
|
|
155
|
-
* resourceTypes: ['items'],
|
|
156
|
-
* syncToken: '*',
|
|
157
|
-
* })
|
|
158
|
-
* ```
|
|
159
|
-
*/
|
|
160
|
-
async sync(syncRequest, requestId) {
|
|
161
|
-
var _a;
|
|
162
|
-
return this.requestSync(syncRequest, requestId, Boolean((_a = syncRequest.commands) === null || _a === void 0 ? void 0 : _a.length));
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Retrieves information about the authenticated user.
|
|
166
|
-
*
|
|
167
|
-
* @returns A promise that resolves to the current user's information.
|
|
168
|
-
*/
|
|
169
|
-
async getUser() {
|
|
170
|
-
const response = await request({
|
|
171
|
-
httpMethod: 'GET',
|
|
172
|
-
baseUri: this.syncApiBase,
|
|
173
|
-
relativePath: ENDPOINT_REST_USER,
|
|
174
|
-
apiToken: this.authToken,
|
|
175
|
-
customFetch: this.customFetch,
|
|
176
|
-
});
|
|
177
|
-
return validateCurrentUser(response.data);
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Retrieves a single active (non-completed) task by its ID.
|
|
181
|
-
*
|
|
182
|
-
* @param id - The unique identifier of the task.
|
|
183
|
-
* @returns A promise that resolves to the requested task.
|
|
184
|
-
*/
|
|
185
|
-
async getTask(id) {
|
|
186
|
-
z.string().parse(id);
|
|
187
|
-
const response = await request({
|
|
188
|
-
httpMethod: 'GET',
|
|
189
|
-
baseUri: this.syncApiBase,
|
|
190
|
-
relativePath: generatePath(ENDPOINT_REST_TASKS, id),
|
|
191
|
-
apiToken: this.authToken,
|
|
192
|
-
customFetch: this.customFetch,
|
|
193
|
-
});
|
|
194
|
-
return validateTask(response.data);
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Retrieves a list of active tasks filtered by specific parameters.
|
|
198
|
-
*
|
|
199
|
-
* @param args - Filter parameters such as project ID, label ID, or due date.
|
|
200
|
-
* @returns A promise that resolves to an array of tasks.
|
|
201
|
-
*/
|
|
202
|
-
async getTasks(args = {}) {
|
|
203
|
-
const { data: { results, nextCursor }, } = await request({
|
|
204
|
-
httpMethod: 'GET',
|
|
205
|
-
baseUri: this.syncApiBase,
|
|
206
|
-
relativePath: ENDPOINT_REST_TASKS,
|
|
207
|
-
apiToken: this.authToken,
|
|
208
|
-
customFetch: this.customFetch,
|
|
209
|
-
payload: args,
|
|
210
|
-
});
|
|
211
|
-
return {
|
|
212
|
-
results: validateTaskArray(results),
|
|
213
|
-
nextCursor,
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* Retrieves tasks filtered by a filter string.
|
|
218
|
-
*
|
|
219
|
-
* @param args - Parameters for filtering tasks, including the query string and optional language.
|
|
220
|
-
* @returns A promise that resolves to a paginated response of tasks.
|
|
221
|
-
*/
|
|
222
|
-
async getTasksByFilter(args) {
|
|
223
|
-
const { data: { results, nextCursor }, } = await request({
|
|
224
|
-
httpMethod: 'GET',
|
|
225
|
-
baseUri: this.syncApiBase,
|
|
226
|
-
relativePath: ENDPOINT_REST_TASKS_FILTER,
|
|
227
|
-
apiToken: this.authToken,
|
|
228
|
-
customFetch: this.customFetch,
|
|
229
|
-
payload: args,
|
|
230
|
-
});
|
|
231
|
-
return {
|
|
232
|
-
results: validateTaskArray(results),
|
|
233
|
-
nextCursor,
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* Retrieves completed tasks by completion date.
|
|
238
|
-
*
|
|
239
|
-
* @param args - Parameters for filtering, including required since, until.
|
|
240
|
-
* @returns A promise that resolves to a paginated response of completed tasks.
|
|
241
|
-
*/
|
|
242
|
-
async getCompletedTasksByCompletionDate(args) {
|
|
243
|
-
const { data: { items, nextCursor }, } = await request({
|
|
244
|
-
httpMethod: 'GET',
|
|
245
|
-
baseUri: this.syncApiBase,
|
|
246
|
-
relativePath: ENDPOINT_REST_TASKS_COMPLETED_BY_COMPLETION_DATE,
|
|
247
|
-
apiToken: this.authToken,
|
|
248
|
-
customFetch: this.customFetch,
|
|
249
|
-
payload: args,
|
|
250
|
-
});
|
|
251
|
-
return {
|
|
252
|
-
items: validateTaskArray(items),
|
|
253
|
-
nextCursor,
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* Retrieves completed tasks by due date.
|
|
258
|
-
*
|
|
259
|
-
* @param args - Parameters for filtering, including required since, until.
|
|
260
|
-
* @returns A promise that resolves to a paginated response of completed tasks.
|
|
261
|
-
*/
|
|
262
|
-
async getCompletedTasksByDueDate(args) {
|
|
263
|
-
const { data: { items, nextCursor }, } = await request({
|
|
264
|
-
httpMethod: 'GET',
|
|
265
|
-
baseUri: this.syncApiBase,
|
|
266
|
-
relativePath: ENDPOINT_REST_TASKS_COMPLETED_BY_DUE_DATE,
|
|
267
|
-
apiToken: this.authToken,
|
|
268
|
-
customFetch: this.customFetch,
|
|
269
|
-
payload: args,
|
|
270
|
-
});
|
|
271
|
-
return {
|
|
272
|
-
items: validateTaskArray(items),
|
|
273
|
-
nextCursor,
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* Searches completed tasks by query string.
|
|
278
|
-
*
|
|
279
|
-
* @param args - Parameters for searching, including the query string.
|
|
280
|
-
* @returns A promise that resolves to a paginated response of completed tasks.
|
|
281
|
-
*/
|
|
282
|
-
async searchCompletedTasks(args) {
|
|
283
|
-
const { data: { items, nextCursor }, } = await request({
|
|
284
|
-
httpMethod: 'GET',
|
|
285
|
-
baseUri: this.syncApiBase,
|
|
286
|
-
relativePath: ENDPOINT_REST_TASKS_COMPLETED_SEARCH,
|
|
287
|
-
apiToken: this.authToken,
|
|
288
|
-
customFetch: this.customFetch,
|
|
289
|
-
payload: args,
|
|
290
|
-
});
|
|
291
|
-
return {
|
|
292
|
-
items: validateTaskArray(items),
|
|
293
|
-
nextCursor,
|
|
294
|
-
};
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* Retrieves all completed tasks with optional filters.
|
|
298
|
-
*
|
|
299
|
-
* Uses offset-based pagination rather than cursor-based.
|
|
300
|
-
*
|
|
301
|
-
* @param args - Optional parameters including project ID, label, date range, and pagination.
|
|
302
|
-
* @returns A promise that resolves to completed tasks with associated project and section data.
|
|
303
|
-
*/
|
|
304
|
-
async getAllCompletedTasks(args = {}) {
|
|
305
|
-
const { since, until } = args, rest = __rest(args, ["since", "until"]);
|
|
306
|
-
const { data } = await request({
|
|
307
|
-
httpMethod: 'GET',
|
|
308
|
-
baseUri: this.syncApiBase,
|
|
309
|
-
relativePath: ENDPOINT_REST_TASKS_COMPLETED,
|
|
310
|
-
apiToken: this.authToken,
|
|
311
|
-
customFetch: this.customFetch,
|
|
312
|
-
payload: Object.assign(Object.assign(Object.assign({}, rest), (since ? { since: since.toISOString() } : {})), (until ? { until: until.toISOString() } : {})),
|
|
313
|
-
});
|
|
314
|
-
return {
|
|
315
|
-
projects: data.projects,
|
|
316
|
-
sections: data.sections,
|
|
317
|
-
items: validateTaskArray(data.items),
|
|
318
|
-
};
|
|
319
|
-
}
|
|
320
|
-
/**
|
|
321
|
-
* Creates a new task with the provided parameters.
|
|
322
|
-
*
|
|
323
|
-
* @param args - Task creation parameters such as content, due date, or priority.
|
|
324
|
-
* @param requestId - Optional custom identifier for the request.
|
|
325
|
-
* @returns A promise that resolves to the created task.
|
|
326
|
-
*/
|
|
327
|
-
async addTask(args, requestId) {
|
|
328
|
-
// Process content based on isUncompletable flag
|
|
329
|
-
const processedArgs = Object.assign(Object.assign({}, args), { content: processTaskContent(args.content, args.isUncompletable) });
|
|
330
|
-
const response = await request({
|
|
331
|
-
httpMethod: 'POST',
|
|
332
|
-
baseUri: this.syncApiBase,
|
|
333
|
-
relativePath: ENDPOINT_REST_TASKS,
|
|
334
|
-
apiToken: this.authToken,
|
|
335
|
-
customFetch: this.customFetch,
|
|
336
|
-
payload: processedArgs,
|
|
337
|
-
requestId: requestId,
|
|
338
|
-
});
|
|
339
|
-
return validateTask(response.data);
|
|
340
|
-
}
|
|
341
|
-
/**
|
|
342
|
-
* Quickly adds a task using natural language processing for due dates.
|
|
343
|
-
*
|
|
344
|
-
* @param args - Quick add task parameters, including content and due date.
|
|
345
|
-
* @returns A promise that resolves to the created task.
|
|
346
|
-
*/
|
|
347
|
-
async quickAddTask(args) {
|
|
348
|
-
// Process text based on isUncompletable flag
|
|
349
|
-
const processedArgs = Object.assign(Object.assign({}, args), { text: processTaskContent(args.text, args.isUncompletable) });
|
|
350
|
-
const response = await request({
|
|
351
|
-
httpMethod: 'POST',
|
|
352
|
-
baseUri: this.syncApiBase,
|
|
353
|
-
relativePath: ENDPOINT_SYNC_QUICK_ADD,
|
|
354
|
-
apiToken: this.authToken,
|
|
355
|
-
customFetch: this.customFetch,
|
|
356
|
-
payload: processedArgs,
|
|
357
|
-
});
|
|
358
|
-
return validateTask(response.data);
|
|
359
|
-
}
|
|
360
|
-
/**
|
|
361
|
-
* Updates an existing task by its ID with the provided parameters.
|
|
362
|
-
*
|
|
363
|
-
* @param id - The unique identifier of the task to update.
|
|
364
|
-
* @param args - Update parameters such as content, priority, or due date. Pass
|
|
365
|
-
* `dueString: null` (or `"no date"`) to clear the due date.
|
|
366
|
-
* @param requestId - Optional custom identifier for the request.
|
|
367
|
-
* @returns A promise that resolves to the updated task.
|
|
368
|
-
*/
|
|
369
|
-
async updateTask(id, args, requestId) {
|
|
370
|
-
z.string().parse(id);
|
|
371
|
-
// Translate SDK alias for due-date clearing to Todoist's accepted payload value.
|
|
372
|
-
const normalizedArgs = args.dueString === null ? Object.assign(Object.assign({}, args), { dueString: 'no date' }) : args;
|
|
373
|
-
// Process content if both content and isUncompletable are provided
|
|
374
|
-
const processedArgs = normalizedArgs.content && normalizedArgs.isUncompletable !== undefined
|
|
375
|
-
? Object.assign(Object.assign({}, normalizedArgs), { content: processTaskContent(normalizedArgs.content, normalizedArgs.isUncompletable) }) : normalizedArgs;
|
|
376
|
-
// Remap `order` → `childOrder` so snakeCaseKeys() produces `child_order`
|
|
377
|
-
const { order } = processedArgs, argsWithoutOrder = __rest(processedArgs, ["order"]);
|
|
378
|
-
const remappedArgs = order !== undefined ? Object.assign(Object.assign({}, argsWithoutOrder), { childOrder: order }) : argsWithoutOrder;
|
|
379
|
-
const response = await request({
|
|
380
|
-
httpMethod: 'POST',
|
|
381
|
-
baseUri: this.syncApiBase,
|
|
382
|
-
relativePath: generatePath(ENDPOINT_REST_TASKS, id),
|
|
383
|
-
apiToken: this.authToken,
|
|
384
|
-
customFetch: this.customFetch,
|
|
385
|
-
payload: remappedArgs,
|
|
386
|
-
requestId: requestId,
|
|
387
|
-
});
|
|
388
|
-
return validateTask(response.data);
|
|
389
|
-
}
|
|
390
|
-
/**
|
|
391
|
-
* Moves existing tasks by their ID to either a different parent/section/project.
|
|
392
|
-
*
|
|
393
|
-
* @param ids - The unique identifier of the tasks to be moved.
|
|
394
|
-
* @param args - The paramets that should contain only one of projectId, sectionId, or parentId
|
|
395
|
-
* @param requestId - Optional custom identifier for the request.
|
|
396
|
-
* @returns - A promise that resolves to an array of the updated tasks.
|
|
397
|
-
*/
|
|
398
|
-
async moveTasks(ids, args, requestId) {
|
|
399
|
-
var _a;
|
|
400
|
-
if (ids.length > MAX_COMMAND_COUNT) {
|
|
401
|
-
throw new TodoistRequestError(`Maximum number of items is ${MAX_COMMAND_COUNT}`, 400);
|
|
402
|
-
}
|
|
403
|
-
const commands = ids.map((id) => ({
|
|
404
|
-
type: 'item_move',
|
|
405
|
-
uuid: uuidv4(),
|
|
406
|
-
args: Object.assign(Object.assign(Object.assign({ id }, spreadIfDefined(args.projectId, (v) => ({ projectId: v }))), spreadIfDefined(args.sectionId, (v) => ({ sectionId: v }))), spreadIfDefined(args.parentId, (v) => ({ parentId: v }))),
|
|
407
|
-
}));
|
|
408
|
-
const syncRequest = {
|
|
409
|
-
commands,
|
|
410
|
-
resourceTypes: ['items'],
|
|
411
|
-
};
|
|
412
|
-
const syncResponse = await this.requestSync(syncRequest, requestId, true);
|
|
413
|
-
if (!((_a = syncResponse.items) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
414
|
-
throw new TodoistRequestError('Tasks not found', 404);
|
|
415
|
-
}
|
|
416
|
-
const syncTasks = syncResponse.items.filter((task) => ids.includes(task.id));
|
|
417
|
-
if (!syncTasks.length) {
|
|
418
|
-
throw new TodoistRequestError('Tasks not found', 404);
|
|
419
|
-
}
|
|
420
|
-
return validateTaskArray(syncTasks);
|
|
421
|
-
}
|
|
422
|
-
/**
|
|
423
|
-
* Moves a task by its ID to either a different parent/section/project.
|
|
424
|
-
*
|
|
425
|
-
* @param id - The unique identifier of the task to be moved.
|
|
426
|
-
* @param args - The parameters that should contain exactly one of projectId, sectionId, or parentId
|
|
427
|
-
* @param requestId - Optional custom identifier for the request.
|
|
428
|
-
* @returns A promise that resolves to the updated task.
|
|
429
|
-
*/
|
|
430
|
-
async moveTask(id, args, requestId) {
|
|
431
|
-
z.string().parse(id);
|
|
432
|
-
const response = await request({
|
|
433
|
-
httpMethod: 'POST',
|
|
434
|
-
baseUri: this.syncApiBase,
|
|
435
|
-
relativePath: generatePath(ENDPOINT_REST_TASKS, id, ENDPOINT_REST_TASK_MOVE),
|
|
436
|
-
apiToken: this.authToken,
|
|
437
|
-
customFetch: this.customFetch,
|
|
438
|
-
payload: Object.assign(Object.assign(Object.assign({}, spreadIfDefined(args.projectId, (v) => ({ project_id: v }))), spreadIfDefined(args.sectionId, (v) => ({ section_id: v }))), spreadIfDefined(args.parentId, (v) => ({ parent_id: v }))),
|
|
439
|
-
requestId: requestId,
|
|
440
|
-
});
|
|
441
|
-
return validateTask(response.data);
|
|
442
|
-
}
|
|
443
|
-
/**
|
|
444
|
-
* Closes (completes) a task by its ID.
|
|
445
|
-
*
|
|
446
|
-
* @param id - The unique identifier of the task to close.
|
|
447
|
-
* @param requestId - Optional custom identifier for the request.
|
|
448
|
-
* @returns A promise that resolves to `true` if successful.
|
|
449
|
-
*/
|
|
450
|
-
async closeTask(id, requestId) {
|
|
451
|
-
z.string().parse(id);
|
|
452
|
-
const response = await request({
|
|
453
|
-
httpMethod: 'POST',
|
|
454
|
-
baseUri: this.syncApiBase,
|
|
455
|
-
relativePath: generatePath(ENDPOINT_REST_TASKS, id, ENDPOINT_REST_TASK_CLOSE),
|
|
456
|
-
apiToken: this.authToken,
|
|
457
|
-
customFetch: this.customFetch,
|
|
458
|
-
requestId: requestId,
|
|
459
|
-
});
|
|
460
|
-
return isSuccess(response);
|
|
461
|
-
}
|
|
462
|
-
/**
|
|
463
|
-
* Reopens a previously closed (completed) task by its ID.
|
|
464
|
-
*
|
|
465
|
-
* @param id - The unique identifier of the task to reopen.
|
|
466
|
-
* @param requestId - Optional custom identifier for the request.
|
|
467
|
-
* @returns A promise that resolves to `true` if successful.
|
|
468
|
-
*/
|
|
469
|
-
async reopenTask(id, requestId) {
|
|
470
|
-
z.string().parse(id);
|
|
471
|
-
const response = await request({
|
|
472
|
-
httpMethod: 'POST',
|
|
473
|
-
baseUri: this.syncApiBase,
|
|
474
|
-
relativePath: generatePath(ENDPOINT_REST_TASKS, id, ENDPOINT_REST_TASK_REOPEN),
|
|
475
|
-
apiToken: this.authToken,
|
|
476
|
-
customFetch: this.customFetch,
|
|
477
|
-
requestId: requestId,
|
|
478
|
-
});
|
|
479
|
-
return isSuccess(response);
|
|
480
|
-
}
|
|
481
|
-
/**
|
|
482
|
-
* Deletes a task by its ID.
|
|
483
|
-
*
|
|
484
|
-
* @param id - The unique identifier of the task to delete.
|
|
485
|
-
* @param requestId - Optional custom identifier for the request.
|
|
486
|
-
* @returns A promise that resolves to `true` if successful.
|
|
487
|
-
*/
|
|
488
|
-
async deleteTask(id, requestId) {
|
|
489
|
-
z.string().parse(id);
|
|
490
|
-
const response = await request({
|
|
491
|
-
httpMethod: 'DELETE',
|
|
492
|
-
baseUri: this.syncApiBase,
|
|
493
|
-
relativePath: generatePath(ENDPOINT_REST_TASKS, id),
|
|
494
|
-
apiToken: this.authToken,
|
|
495
|
-
customFetch: this.customFetch,
|
|
496
|
-
requestId: requestId,
|
|
497
|
-
});
|
|
498
|
-
return isSuccess(response);
|
|
499
|
-
}
|
|
500
|
-
/**
|
|
501
|
-
* Retrieves a project by its ID.
|
|
502
|
-
*
|
|
503
|
-
* @param id - The unique identifier of the project.
|
|
504
|
-
* @returns A promise that resolves to the requested project.
|
|
505
|
-
*/
|
|
506
|
-
async getProject(id) {
|
|
507
|
-
z.string().parse(id);
|
|
508
|
-
const response = await request({
|
|
509
|
-
httpMethod: 'GET',
|
|
510
|
-
baseUri: this.syncApiBase,
|
|
511
|
-
relativePath: generatePath(ENDPOINT_REST_PROJECTS, id),
|
|
512
|
-
apiToken: this.authToken,
|
|
513
|
-
customFetch: this.customFetch,
|
|
514
|
-
});
|
|
515
|
-
return validateProject(response.data);
|
|
516
|
-
}
|
|
517
|
-
/**
|
|
518
|
-
* Retrieves all projects with optional filters.
|
|
519
|
-
*
|
|
520
|
-
* @param args - Optional filters for retrieving projects.
|
|
521
|
-
* @returns A promise that resolves to an array of projects.
|
|
522
|
-
*/
|
|
523
|
-
async getProjects(args = {}) {
|
|
524
|
-
const { data: { results, nextCursor }, } = await request({
|
|
525
|
-
httpMethod: 'GET',
|
|
526
|
-
baseUri: this.syncApiBase,
|
|
527
|
-
relativePath: ENDPOINT_REST_PROJECTS,
|
|
528
|
-
apiToken: this.authToken,
|
|
529
|
-
customFetch: this.customFetch,
|
|
530
|
-
payload: args,
|
|
531
|
-
});
|
|
532
|
-
return {
|
|
533
|
-
results: validateProjectArray(results),
|
|
534
|
-
nextCursor,
|
|
535
|
-
};
|
|
536
|
-
}
|
|
537
|
-
/**
|
|
538
|
-
* Searches projects by name.
|
|
539
|
-
*
|
|
540
|
-
* @param args - Search parameters including the query string.
|
|
541
|
-
* @returns A promise that resolves to a paginated response of projects.
|
|
542
|
-
*/
|
|
543
|
-
async searchProjects(args) {
|
|
544
|
-
const { data: { results, nextCursor }, } = await request({
|
|
545
|
-
httpMethod: 'GET',
|
|
546
|
-
baseUri: this.syncApiBase,
|
|
547
|
-
relativePath: ENDPOINT_REST_PROJECTS_SEARCH,
|
|
548
|
-
apiToken: this.authToken,
|
|
549
|
-
customFetch: this.customFetch,
|
|
550
|
-
payload: args,
|
|
551
|
-
});
|
|
552
|
-
return {
|
|
553
|
-
results: validateProjectArray(results),
|
|
554
|
-
nextCursor,
|
|
555
|
-
};
|
|
556
|
-
}
|
|
557
|
-
/**
|
|
558
|
-
* Retrieves all archived projects with optional filters.
|
|
559
|
-
*
|
|
560
|
-
* @param args - Optional filters for retrieving archived projects.
|
|
561
|
-
* @returns A promise that resolves to an array of archived projects.
|
|
562
|
-
*/
|
|
563
|
-
async getArchivedProjects(args = {}) {
|
|
564
|
-
const { data: { results, nextCursor }, } = await request({
|
|
565
|
-
httpMethod: 'GET',
|
|
566
|
-
baseUri: this.syncApiBase,
|
|
567
|
-
relativePath: ENDPOINT_REST_PROJECTS_ARCHIVED,
|
|
568
|
-
apiToken: this.authToken,
|
|
569
|
-
customFetch: this.customFetch,
|
|
570
|
-
payload: args,
|
|
571
|
-
});
|
|
572
|
-
return {
|
|
573
|
-
results: validateProjectArray(results),
|
|
574
|
-
nextCursor,
|
|
575
|
-
};
|
|
576
|
-
}
|
|
577
|
-
/**
|
|
578
|
-
* Creates a new project with the provided parameters.
|
|
579
|
-
*
|
|
580
|
-
* @param args - Project creation parameters such as name or color.
|
|
581
|
-
* @param requestId - Optional custom identifier for the request.
|
|
582
|
-
* @returns A promise that resolves to the created project.
|
|
583
|
-
*/
|
|
584
|
-
async addProject(args, requestId) {
|
|
585
|
-
const response = await request({
|
|
586
|
-
httpMethod: 'POST',
|
|
587
|
-
baseUri: this.syncApiBase,
|
|
588
|
-
relativePath: ENDPOINT_REST_PROJECTS,
|
|
589
|
-
apiToken: this.authToken,
|
|
590
|
-
customFetch: this.customFetch,
|
|
591
|
-
payload: args,
|
|
592
|
-
requestId: requestId,
|
|
593
|
-
});
|
|
594
|
-
return validateProject(response.data);
|
|
595
|
-
}
|
|
596
|
-
/**
|
|
597
|
-
* Updates an existing project by its ID with the provided parameters.
|
|
598
|
-
*
|
|
599
|
-
* @param id - The unique identifier of the project to update.
|
|
600
|
-
* @param args - Update parameters such as name or color.
|
|
601
|
-
* @param requestId - Optional custom identifier for the request.
|
|
602
|
-
* @returns A promise that resolves to the updated project.
|
|
603
|
-
*/
|
|
604
|
-
async updateProject(id, args, requestId) {
|
|
605
|
-
z.string().parse(id);
|
|
606
|
-
const response = await request({
|
|
607
|
-
httpMethod: 'POST',
|
|
608
|
-
baseUri: this.syncApiBase,
|
|
609
|
-
relativePath: generatePath(ENDPOINT_REST_PROJECTS, id),
|
|
610
|
-
apiToken: this.authToken,
|
|
611
|
-
customFetch: this.customFetch,
|
|
612
|
-
payload: args,
|
|
613
|
-
requestId: requestId,
|
|
614
|
-
});
|
|
615
|
-
return validateProject(response.data);
|
|
616
|
-
}
|
|
617
|
-
/**
|
|
618
|
-
* Deletes a project by its ID.
|
|
619
|
-
*
|
|
620
|
-
* @param id - The unique identifier of the project to delete.
|
|
621
|
-
* @param requestId - Optional custom identifier for the request.
|
|
622
|
-
* @returns A promise that resolves to `true` if successful.
|
|
623
|
-
*/
|
|
624
|
-
async deleteProject(id, requestId) {
|
|
625
|
-
z.string().parse(id);
|
|
626
|
-
const response = await request({
|
|
627
|
-
httpMethod: 'DELETE',
|
|
628
|
-
baseUri: this.syncApiBase,
|
|
629
|
-
relativePath: generatePath(ENDPOINT_REST_PROJECTS, id),
|
|
630
|
-
apiToken: this.authToken,
|
|
631
|
-
customFetch: this.customFetch,
|
|
632
|
-
requestId: requestId,
|
|
633
|
-
});
|
|
634
|
-
return isSuccess(response);
|
|
635
|
-
}
|
|
636
|
-
/**
|
|
637
|
-
* Archives a project by its ID.
|
|
638
|
-
*
|
|
639
|
-
* @param id - The unique identifier of the project to archive.
|
|
640
|
-
* @param requestId - Optional custom identifier for the request.
|
|
641
|
-
* @returns A promise that resolves to the updated project.
|
|
642
|
-
*/
|
|
643
|
-
async archiveProject(id, requestId) {
|
|
644
|
-
z.string().parse(id);
|
|
645
|
-
const response = await request({
|
|
646
|
-
httpMethod: 'POST',
|
|
647
|
-
baseUri: this.syncApiBase,
|
|
648
|
-
relativePath: generatePath(ENDPOINT_REST_PROJECTS, id, PROJECT_ARCHIVE),
|
|
649
|
-
apiToken: this.authToken,
|
|
650
|
-
customFetch: this.customFetch,
|
|
651
|
-
requestId: requestId,
|
|
652
|
-
});
|
|
653
|
-
return validateProject(response.data);
|
|
654
|
-
}
|
|
655
|
-
/**
|
|
656
|
-
* Unarchives a project by its ID.
|
|
657
|
-
*
|
|
658
|
-
* @param id - The unique identifier of the project to unarchive.
|
|
659
|
-
* @param requestId - Optional custom identifier for the request.
|
|
660
|
-
* @returns A promise that resolves to the updated project.
|
|
661
|
-
*/
|
|
662
|
-
async unarchiveProject(id, requestId) {
|
|
663
|
-
z.string().parse(id);
|
|
664
|
-
const response = await request({
|
|
665
|
-
httpMethod: 'POST',
|
|
666
|
-
baseUri: this.syncApiBase,
|
|
667
|
-
relativePath: generatePath(ENDPOINT_REST_PROJECTS, id, PROJECT_UNARCHIVE),
|
|
668
|
-
apiToken: this.authToken,
|
|
669
|
-
customFetch: this.customFetch,
|
|
670
|
-
requestId: requestId,
|
|
671
|
-
});
|
|
672
|
-
return validateProject(response.data);
|
|
673
|
-
}
|
|
674
|
-
/**
|
|
675
|
-
* Moves a project to a workspace.
|
|
676
|
-
*
|
|
677
|
-
* @param args - The arguments for moving the project.
|
|
678
|
-
* @param requestId - Optional custom identifier for the request.
|
|
679
|
-
* @returns A promise that resolves to the moved project.
|
|
680
|
-
*/
|
|
681
|
-
async moveProjectToWorkspace(args, requestId) {
|
|
682
|
-
const response = await request({
|
|
683
|
-
httpMethod: 'POST',
|
|
684
|
-
baseUri: this.syncApiBase,
|
|
685
|
-
relativePath: ENDPOINT_REST_PROJECTS_MOVE_TO_WORKSPACE,
|
|
686
|
-
apiToken: this.authToken,
|
|
687
|
-
customFetch: this.customFetch,
|
|
688
|
-
payload: args,
|
|
689
|
-
requestId: requestId,
|
|
690
|
-
});
|
|
691
|
-
return validateProject(response.data.project);
|
|
692
|
-
}
|
|
693
|
-
/**
|
|
694
|
-
* Moves a project to personal.
|
|
695
|
-
*
|
|
696
|
-
* @param args - The arguments for moving the project.
|
|
697
|
-
* @param requestId - Optional custom identifier for the request.
|
|
698
|
-
* @returns A promise that resolves to the moved project.
|
|
699
|
-
*/
|
|
700
|
-
async moveProjectToPersonal(args, requestId) {
|
|
701
|
-
const response = await request({
|
|
702
|
-
httpMethod: 'POST',
|
|
703
|
-
baseUri: this.syncApiBase,
|
|
704
|
-
relativePath: ENDPOINT_REST_PROJECTS_MOVE_TO_PERSONAL,
|
|
705
|
-
apiToken: this.authToken,
|
|
706
|
-
customFetch: this.customFetch,
|
|
707
|
-
payload: args,
|
|
708
|
-
requestId: requestId,
|
|
709
|
-
});
|
|
710
|
-
return validateProject(response.data.project);
|
|
711
|
-
}
|
|
712
|
-
/**
|
|
713
|
-
* Counts the number of archived projects.
|
|
714
|
-
*
|
|
715
|
-
* @param args - Optional parameters to filter the count.
|
|
716
|
-
* @returns A promise that resolves to the count of archived projects.
|
|
717
|
-
*/
|
|
718
|
-
async getArchivedProjectsCount(args = {}) {
|
|
719
|
-
const { data } = await request({
|
|
720
|
-
httpMethod: 'GET',
|
|
721
|
-
baseUri: this.syncApiBase,
|
|
722
|
-
relativePath: ENDPOINT_REST_PROJECTS_ARCHIVED_COUNT,
|
|
723
|
-
apiToken: this.authToken,
|
|
724
|
-
customFetch: this.customFetch,
|
|
725
|
-
payload: args,
|
|
726
|
-
});
|
|
727
|
-
return data;
|
|
728
|
-
}
|
|
729
|
-
/**
|
|
730
|
-
* Retrieves the role-to-action permission mappings for projects.
|
|
731
|
-
*
|
|
732
|
-
* @returns A promise that resolves to the permission mappings.
|
|
733
|
-
*/
|
|
734
|
-
async getProjectPermissions() {
|
|
735
|
-
const { data } = await request({
|
|
736
|
-
httpMethod: 'GET',
|
|
737
|
-
baseUri: this.syncApiBase,
|
|
738
|
-
relativePath: ENDPOINT_REST_PROJECTS_PERMISSIONS,
|
|
739
|
-
apiToken: this.authToken,
|
|
740
|
-
customFetch: this.customFetch,
|
|
741
|
-
});
|
|
742
|
-
return data;
|
|
743
|
-
}
|
|
744
|
-
/**
|
|
745
|
-
* Retrieves full project data including tasks, sections, collaborators, and notes.
|
|
746
|
-
*
|
|
747
|
-
* @param id - The unique identifier of the project.
|
|
748
|
-
* @param args - Optional parameters.
|
|
749
|
-
* @returns A promise that resolves to the full project data.
|
|
750
|
-
*/
|
|
751
|
-
async getFullProject(id, args = {}) {
|
|
752
|
-
z.string().parse(id);
|
|
753
|
-
const { data } = await request({
|
|
754
|
-
httpMethod: 'GET',
|
|
755
|
-
baseUri: this.syncApiBase,
|
|
756
|
-
relativePath: generatePath(ENDPOINT_REST_PROJECTS, id, ENDPOINT_REST_PROJECT_FULL),
|
|
757
|
-
apiToken: this.authToken,
|
|
758
|
-
customFetch: this.customFetch,
|
|
759
|
-
payload: args,
|
|
760
|
-
});
|
|
761
|
-
return {
|
|
762
|
-
project: data.project ? validateProject(data.project) : null,
|
|
763
|
-
commentsCount: data.commentsCount,
|
|
764
|
-
tasks: validateTaskArray(data.tasks),
|
|
765
|
-
sections: validateSectionArray(data.sections),
|
|
766
|
-
collaborators: validateUserArray(data.collaborators),
|
|
767
|
-
notes: validateCommentArray(data.notes),
|
|
768
|
-
};
|
|
769
|
-
}
|
|
770
|
-
/**
|
|
771
|
-
* Joins a shared project by its ID.
|
|
772
|
-
*
|
|
773
|
-
* @param id - The unique identifier of the project to join.
|
|
774
|
-
* @param requestId - Optional custom identifier for the request.
|
|
775
|
-
* @returns A promise that resolves to the joined project.
|
|
776
|
-
*/
|
|
777
|
-
async joinProject(id, requestId) {
|
|
778
|
-
z.string().parse(id);
|
|
779
|
-
const response = await request({
|
|
780
|
-
httpMethod: 'POST',
|
|
781
|
-
baseUri: this.syncApiBase,
|
|
782
|
-
relativePath: generatePath(ENDPOINT_REST_PROJECTS, id, ENDPOINT_REST_PROJECT_JOIN),
|
|
783
|
-
apiToken: this.authToken,
|
|
784
|
-
customFetch: this.customFetch,
|
|
785
|
-
requestId: requestId,
|
|
786
|
-
});
|
|
787
|
-
return validateProject(response.data);
|
|
788
|
-
}
|
|
789
|
-
/**
|
|
790
|
-
* Retrieves a list of collaborators for a specific project.
|
|
791
|
-
*
|
|
792
|
-
* @param projectId - The unique identifier of the project.
|
|
793
|
-
* @param args - Optional parameters to filter collaborators.
|
|
794
|
-
* @returns A promise that resolves to an array of collaborators for the project.
|
|
795
|
-
*/
|
|
796
|
-
async getProjectCollaborators(projectId, args = {}) {
|
|
797
|
-
z.string().parse(projectId);
|
|
798
|
-
const { data: { results, nextCursor }, } = await request({
|
|
799
|
-
httpMethod: 'GET',
|
|
800
|
-
baseUri: this.syncApiBase,
|
|
801
|
-
relativePath: generatePath(ENDPOINT_REST_PROJECTS, projectId, ENDPOINT_REST_PROJECT_COLLABORATORS),
|
|
802
|
-
apiToken: this.authToken,
|
|
803
|
-
customFetch: this.customFetch,
|
|
804
|
-
payload: args,
|
|
805
|
-
});
|
|
806
|
-
return {
|
|
807
|
-
results: validateUserArray(results),
|
|
808
|
-
nextCursor,
|
|
809
|
-
};
|
|
810
|
-
}
|
|
811
|
-
// ── Insights ──
|
|
812
|
-
/**
|
|
813
|
-
* Retrieves activity statistics for a project.
|
|
814
|
-
*
|
|
815
|
-
* @param projectId - The unique identifier of the project.
|
|
816
|
-
* @param args - Optional parameters including weeks and weekly counts flag.
|
|
817
|
-
* @returns A promise that resolves to the project activity stats.
|
|
818
|
-
*/
|
|
819
|
-
async getProjectActivityStats(projectId, args = {}) {
|
|
820
|
-
z.string().parse(projectId);
|
|
821
|
-
const response = await request({
|
|
822
|
-
httpMethod: 'GET',
|
|
823
|
-
baseUri: this.syncApiBase,
|
|
824
|
-
relativePath: getProjectInsightsActivityStatsEndpoint(projectId),
|
|
825
|
-
apiToken: this.authToken,
|
|
826
|
-
customFetch: this.customFetch,
|
|
827
|
-
payload: Object.assign({ objectType: 'ITEM', eventType: 'COMPLETED' }, args),
|
|
828
|
-
});
|
|
829
|
-
return validateProjectActivityStats(response.data);
|
|
830
|
-
}
|
|
831
|
-
/**
|
|
832
|
-
* Retrieves the health status of a project.
|
|
833
|
-
*
|
|
834
|
-
* @param projectId - The unique identifier of the project.
|
|
835
|
-
* @returns A promise that resolves to the project health data.
|
|
836
|
-
*/
|
|
837
|
-
async getProjectHealth(projectId) {
|
|
838
|
-
z.string().parse(projectId);
|
|
839
|
-
const response = await request({
|
|
840
|
-
httpMethod: 'GET',
|
|
841
|
-
baseUri: this.syncApiBase,
|
|
842
|
-
relativePath: getProjectInsightsHealthEndpoint(projectId),
|
|
843
|
-
apiToken: this.authToken,
|
|
844
|
-
customFetch: this.customFetch,
|
|
845
|
-
});
|
|
846
|
-
return validateProjectHealth(response.data);
|
|
847
|
-
}
|
|
848
|
-
/**
|
|
849
|
-
* Retrieves the health context for a project, including metrics and task details.
|
|
850
|
-
*
|
|
851
|
-
* @param projectId - The unique identifier of the project.
|
|
852
|
-
* @returns A promise that resolves to the project health context.
|
|
853
|
-
*/
|
|
854
|
-
async getProjectHealthContext(projectId) {
|
|
855
|
-
z.string().parse(projectId);
|
|
856
|
-
const response = await request({
|
|
857
|
-
httpMethod: 'GET',
|
|
858
|
-
baseUri: this.syncApiBase,
|
|
859
|
-
relativePath: getProjectInsightsHealthContextEndpoint(projectId),
|
|
860
|
-
apiToken: this.authToken,
|
|
861
|
-
customFetch: this.customFetch,
|
|
862
|
-
});
|
|
863
|
-
return validateProjectHealthContext(response.data);
|
|
864
|
-
}
|
|
865
|
-
/**
|
|
866
|
-
* Retrieves progress information for a project.
|
|
867
|
-
*
|
|
868
|
-
* @param projectId - The unique identifier of the project.
|
|
869
|
-
* @returns A promise that resolves to the project progress data.
|
|
870
|
-
*/
|
|
871
|
-
async getProjectProgress(projectId) {
|
|
872
|
-
z.string().parse(projectId);
|
|
873
|
-
const response = await request({
|
|
874
|
-
httpMethod: 'GET',
|
|
875
|
-
baseUri: this.syncApiBase,
|
|
876
|
-
relativePath: getProjectInsightsProgressEndpoint(projectId),
|
|
877
|
-
apiToken: this.authToken,
|
|
878
|
-
customFetch: this.customFetch,
|
|
879
|
-
});
|
|
880
|
-
return validateProjectProgress(response.data);
|
|
881
|
-
}
|
|
882
|
-
/**
|
|
883
|
-
* Retrieves insights for all projects in a workspace.
|
|
884
|
-
*
|
|
885
|
-
* @param workspaceId - The unique identifier of the workspace.
|
|
886
|
-
* @param args - Optional parameters including project IDs filter.
|
|
887
|
-
* @returns A promise that resolves to workspace insights data.
|
|
888
|
-
*/
|
|
889
|
-
async getWorkspaceInsights(workspaceId, args = {}) {
|
|
890
|
-
z.string().parse(workspaceId);
|
|
891
|
-
const response = await request({
|
|
892
|
-
httpMethod: 'GET',
|
|
893
|
-
baseUri: this.syncApiBase,
|
|
894
|
-
relativePath: getWorkspaceInsightsEndpoint(workspaceId),
|
|
895
|
-
apiToken: this.authToken,
|
|
896
|
-
customFetch: this.customFetch,
|
|
897
|
-
payload: Object.assign(Object.assign({}, args), (args.projectIds ? { projectIds: args.projectIds.join(',') } : {})),
|
|
898
|
-
});
|
|
899
|
-
return validateWorkspaceInsights(response.data);
|
|
900
|
-
}
|
|
901
|
-
/**
|
|
902
|
-
* Triggers a health analysis for a project.
|
|
903
|
-
*
|
|
904
|
-
* @param projectId - The unique identifier of the project.
|
|
905
|
-
* @param requestId - Optional custom identifier for the request.
|
|
906
|
-
* @returns A promise that resolves to the updated project health data.
|
|
907
|
-
*/
|
|
908
|
-
async analyzeProjectHealth(projectId, requestId) {
|
|
909
|
-
z.string().parse(projectId);
|
|
910
|
-
const response = await request({
|
|
911
|
-
httpMethod: 'POST',
|
|
912
|
-
baseUri: this.syncApiBase,
|
|
913
|
-
relativePath: getProjectInsightsHealthAnalyzeEndpoint(projectId),
|
|
914
|
-
apiToken: this.authToken,
|
|
915
|
-
customFetch: this.customFetch,
|
|
916
|
-
requestId: requestId,
|
|
917
|
-
});
|
|
918
|
-
return validateProjectHealth(response.data);
|
|
919
|
-
}
|
|
920
|
-
// ── Sections ──
|
|
921
|
-
/**
|
|
922
|
-
* Retrieves all sections within a specific project or matching criteria.
|
|
923
|
-
*
|
|
924
|
-
* @param args - Filter parameters such as project ID. If no projectId is provided,
|
|
925
|
-
* all sections are returned.
|
|
926
|
-
* @returns A promise that resolves to an array of sections.
|
|
927
|
-
*/
|
|
928
|
-
async getSections(args) {
|
|
929
|
-
const { data: { results, nextCursor }, } = await request({
|
|
930
|
-
httpMethod: 'GET',
|
|
931
|
-
baseUri: this.syncApiBase,
|
|
932
|
-
relativePath: ENDPOINT_REST_SECTIONS,
|
|
933
|
-
apiToken: this.authToken,
|
|
934
|
-
customFetch: this.customFetch,
|
|
935
|
-
payload: args,
|
|
936
|
-
});
|
|
937
|
-
return {
|
|
938
|
-
results: validateSectionArray(results),
|
|
939
|
-
nextCursor,
|
|
940
|
-
};
|
|
941
|
-
}
|
|
942
|
-
/**
|
|
943
|
-
* Searches sections by name.
|
|
944
|
-
*
|
|
945
|
-
* @param args - Search parameters including the query string.
|
|
946
|
-
* @returns A promise that resolves to a paginated response of sections.
|
|
947
|
-
*/
|
|
948
|
-
async searchSections(args) {
|
|
949
|
-
const { data: { results, nextCursor }, } = await request({
|
|
950
|
-
httpMethod: 'GET',
|
|
951
|
-
baseUri: this.syncApiBase,
|
|
952
|
-
relativePath: ENDPOINT_REST_SECTIONS_SEARCH,
|
|
953
|
-
apiToken: this.authToken,
|
|
954
|
-
customFetch: this.customFetch,
|
|
955
|
-
payload: args,
|
|
956
|
-
});
|
|
957
|
-
return {
|
|
958
|
-
results: validateSectionArray(results),
|
|
959
|
-
nextCursor,
|
|
960
|
-
};
|
|
961
|
-
}
|
|
962
|
-
/**
|
|
963
|
-
* Retrieves a single section by its ID.
|
|
964
|
-
*
|
|
965
|
-
* @param id - The unique identifier of the section.
|
|
966
|
-
* @returns A promise that resolves to the requested section.
|
|
967
|
-
*/
|
|
968
|
-
async getSection(id) {
|
|
969
|
-
z.string().parse(id);
|
|
970
|
-
const response = await request({
|
|
971
|
-
httpMethod: 'GET',
|
|
972
|
-
baseUri: this.syncApiBase,
|
|
973
|
-
relativePath: generatePath(ENDPOINT_REST_SECTIONS, id),
|
|
974
|
-
apiToken: this.authToken,
|
|
975
|
-
customFetch: this.customFetch,
|
|
976
|
-
});
|
|
977
|
-
return validateSection(response.data);
|
|
978
|
-
}
|
|
979
|
-
/**
|
|
980
|
-
* Creates a new section within a project.
|
|
981
|
-
*
|
|
982
|
-
* @param args - Section creation parameters such as name or project ID.
|
|
983
|
-
* @param requestId - Optional custom identifier for the request.
|
|
984
|
-
* @returns A promise that resolves to the created section.
|
|
985
|
-
*/
|
|
986
|
-
async addSection(args, requestId) {
|
|
987
|
-
const response = await request({
|
|
988
|
-
httpMethod: 'POST',
|
|
989
|
-
baseUri: this.syncApiBase,
|
|
990
|
-
relativePath: ENDPOINT_REST_SECTIONS,
|
|
991
|
-
apiToken: this.authToken,
|
|
992
|
-
customFetch: this.customFetch,
|
|
993
|
-
payload: args,
|
|
994
|
-
requestId: requestId,
|
|
995
|
-
});
|
|
996
|
-
return validateSection(response.data);
|
|
997
|
-
}
|
|
998
|
-
/**
|
|
999
|
-
* Updates a section by its ID with the provided parameters.
|
|
1000
|
-
*
|
|
1001
|
-
* @param id - The unique identifier of the section to update.
|
|
1002
|
-
* @param args - Update parameters such as name or project ID.
|
|
1003
|
-
* @param requestId - Optional custom identifier for the request.
|
|
1004
|
-
* @returns A promise that resolves to the updated section.
|
|
1005
|
-
*/
|
|
1006
|
-
async updateSection(id, args, requestId) {
|
|
1007
|
-
z.string().parse(id);
|
|
1008
|
-
const response = await request({
|
|
1009
|
-
httpMethod: 'POST',
|
|
1010
|
-
baseUri: this.syncApiBase,
|
|
1011
|
-
relativePath: generatePath(ENDPOINT_REST_SECTIONS, id),
|
|
1012
|
-
apiToken: this.authToken,
|
|
1013
|
-
customFetch: this.customFetch,
|
|
1014
|
-
payload: args,
|
|
1015
|
-
requestId: requestId,
|
|
1016
|
-
});
|
|
1017
|
-
return validateSection(response.data);
|
|
1018
|
-
}
|
|
1019
|
-
/**
|
|
1020
|
-
* Deletes a section by its ID.
|
|
1021
|
-
*
|
|
1022
|
-
* @param id - The unique identifier of the section to delete.
|
|
1023
|
-
* @param requestId - Optional custom identifier for the request.
|
|
1024
|
-
* @returns A promise that resolves to `true` if successful.
|
|
1025
|
-
*/
|
|
1026
|
-
async deleteSection(id, requestId) {
|
|
1027
|
-
z.string().parse(id);
|
|
1028
|
-
const response = await request({
|
|
1029
|
-
httpMethod: 'DELETE',
|
|
1030
|
-
baseUri: this.syncApiBase,
|
|
1031
|
-
relativePath: generatePath(ENDPOINT_REST_SECTIONS, id),
|
|
1032
|
-
apiToken: this.authToken,
|
|
1033
|
-
customFetch: this.customFetch,
|
|
1034
|
-
requestId: requestId,
|
|
1035
|
-
});
|
|
1036
|
-
return isSuccess(response);
|
|
1037
|
-
}
|
|
1038
|
-
/**
|
|
1039
|
-
* Archives a section by its ID.
|
|
1040
|
-
*
|
|
1041
|
-
* @param id - The unique identifier of the section to archive.
|
|
1042
|
-
* @param requestId - Optional custom identifier for the request.
|
|
1043
|
-
* @returns A promise that resolves to the updated section.
|
|
1044
|
-
*/
|
|
1045
|
-
async archiveSection(id, requestId) {
|
|
1046
|
-
z.string().parse(id);
|
|
1047
|
-
const response = await request({
|
|
1048
|
-
httpMethod: 'POST',
|
|
1049
|
-
baseUri: this.syncApiBase,
|
|
1050
|
-
relativePath: generatePath(ENDPOINT_REST_SECTIONS, id, SECTION_ARCHIVE),
|
|
1051
|
-
apiToken: this.authToken,
|
|
1052
|
-
customFetch: this.customFetch,
|
|
1053
|
-
requestId: requestId,
|
|
1054
|
-
});
|
|
1055
|
-
return validateSection(response.data);
|
|
1056
|
-
}
|
|
1057
|
-
/**
|
|
1058
|
-
* Unarchives a section by its ID.
|
|
1059
|
-
*
|
|
1060
|
-
* @param id - The unique identifier of the section to unarchive.
|
|
1061
|
-
* @param requestId - Optional custom identifier for the request.
|
|
1062
|
-
* @returns A promise that resolves to the updated section.
|
|
1063
|
-
*/
|
|
1064
|
-
async unarchiveSection(id, requestId) {
|
|
1065
|
-
z.string().parse(id);
|
|
1066
|
-
const response = await request({
|
|
1067
|
-
httpMethod: 'POST',
|
|
1068
|
-
baseUri: this.syncApiBase,
|
|
1069
|
-
relativePath: generatePath(ENDPOINT_REST_SECTIONS, id, SECTION_UNARCHIVE),
|
|
1070
|
-
apiToken: this.authToken,
|
|
1071
|
-
customFetch: this.customFetch,
|
|
1072
|
-
requestId: requestId,
|
|
1073
|
-
});
|
|
1074
|
-
return validateSection(response.data);
|
|
1075
|
-
}
|
|
1076
|
-
/**
|
|
1077
|
-
* Retrieves a label by its ID.
|
|
1078
|
-
*
|
|
1079
|
-
* @param id - The unique identifier of the label.
|
|
1080
|
-
* @returns A promise that resolves to the requested label.
|
|
1081
|
-
*/
|
|
1082
|
-
async getLabel(id) {
|
|
1083
|
-
z.string().parse(id);
|
|
1084
|
-
const response = await request({
|
|
1085
|
-
httpMethod: 'GET',
|
|
1086
|
-
baseUri: this.syncApiBase,
|
|
1087
|
-
relativePath: generatePath(ENDPOINT_REST_LABELS, id),
|
|
1088
|
-
apiToken: this.authToken,
|
|
1089
|
-
customFetch: this.customFetch,
|
|
1090
|
-
});
|
|
1091
|
-
return validateLabel(response.data);
|
|
1092
|
-
}
|
|
1093
|
-
/**
|
|
1094
|
-
* Retrieves all labels.
|
|
1095
|
-
*
|
|
1096
|
-
* @param args - Optional filter parameters.
|
|
1097
|
-
* @returns A promise that resolves to an array of labels.
|
|
1098
|
-
*/
|
|
1099
|
-
async getLabels(args = {}) {
|
|
1100
|
-
const { data: { results, nextCursor }, } = await request({
|
|
1101
|
-
httpMethod: 'GET',
|
|
1102
|
-
baseUri: this.syncApiBase,
|
|
1103
|
-
relativePath: ENDPOINT_REST_LABELS,
|
|
1104
|
-
apiToken: this.authToken,
|
|
1105
|
-
customFetch: this.customFetch,
|
|
1106
|
-
payload: args,
|
|
1107
|
-
});
|
|
1108
|
-
return {
|
|
1109
|
-
results: validateLabelArray(results),
|
|
1110
|
-
nextCursor,
|
|
1111
|
-
};
|
|
1112
|
-
}
|
|
1113
|
-
/**
|
|
1114
|
-
* Searches labels by name.
|
|
1115
|
-
*
|
|
1116
|
-
* @param args - Search parameters including the query string.
|
|
1117
|
-
* @returns A promise that resolves to a paginated response of labels.
|
|
1118
|
-
*/
|
|
1119
|
-
async searchLabels(args) {
|
|
1120
|
-
const { data: { results, nextCursor }, } = await request({
|
|
1121
|
-
httpMethod: 'GET',
|
|
1122
|
-
baseUri: this.syncApiBase,
|
|
1123
|
-
relativePath: ENDPOINT_REST_LABELS_SEARCH,
|
|
1124
|
-
apiToken: this.authToken,
|
|
1125
|
-
customFetch: this.customFetch,
|
|
1126
|
-
payload: args,
|
|
1127
|
-
});
|
|
1128
|
-
return {
|
|
1129
|
-
results: validateLabelArray(results),
|
|
1130
|
-
nextCursor,
|
|
1131
|
-
};
|
|
1132
|
-
}
|
|
1133
|
-
/**
|
|
1134
|
-
* Adds a new label.
|
|
1135
|
-
*
|
|
1136
|
-
* @param args - Label creation parameters such as name.
|
|
1137
|
-
* @param requestId - Optional custom identifier for the request.
|
|
1138
|
-
* @returns A promise that resolves to the created label.
|
|
1139
|
-
*/
|
|
1140
|
-
async addLabel(args, requestId) {
|
|
1141
|
-
const response = await request({
|
|
1142
|
-
httpMethod: 'POST',
|
|
1143
|
-
baseUri: this.syncApiBase,
|
|
1144
|
-
relativePath: ENDPOINT_REST_LABELS,
|
|
1145
|
-
apiToken: this.authToken,
|
|
1146
|
-
customFetch: this.customFetch,
|
|
1147
|
-
payload: args,
|
|
1148
|
-
requestId: requestId,
|
|
1149
|
-
});
|
|
1150
|
-
return validateLabel(response.data);
|
|
1151
|
-
}
|
|
1152
|
-
/**
|
|
1153
|
-
* Updates an existing label by its ID.
|
|
1154
|
-
*
|
|
1155
|
-
* @param id - The unique identifier of the label to update.
|
|
1156
|
-
* @param args - Update parameters such as name or color.
|
|
1157
|
-
* @param requestId - Optional custom identifier for the request.
|
|
1158
|
-
* @returns A promise that resolves to the updated label.
|
|
1159
|
-
*/
|
|
1160
|
-
async updateLabel(id, args, requestId) {
|
|
1161
|
-
z.string().parse(id);
|
|
1162
|
-
const response = await request({
|
|
1163
|
-
httpMethod: 'POST',
|
|
1164
|
-
baseUri: this.syncApiBase,
|
|
1165
|
-
relativePath: generatePath(ENDPOINT_REST_LABELS, id),
|
|
1166
|
-
apiToken: this.authToken,
|
|
1167
|
-
customFetch: this.customFetch,
|
|
1168
|
-
payload: args,
|
|
1169
|
-
requestId: requestId,
|
|
1170
|
-
});
|
|
1171
|
-
return validateLabel(response.data);
|
|
1172
|
-
}
|
|
1173
|
-
/**
|
|
1174
|
-
* Deletes a label by its ID.
|
|
1175
|
-
*
|
|
1176
|
-
* @param id - The unique identifier of the label to delete.
|
|
1177
|
-
* @param requestId - Optional custom identifier for the request.
|
|
1178
|
-
* @returns A promise that resolves to `true` if successful.
|
|
1179
|
-
*/
|
|
1180
|
-
async deleteLabel(id, requestId) {
|
|
1181
|
-
z.string().parse(id);
|
|
1182
|
-
const response = await request({
|
|
1183
|
-
httpMethod: 'DELETE',
|
|
1184
|
-
baseUri: this.syncApiBase,
|
|
1185
|
-
relativePath: generatePath(ENDPOINT_REST_LABELS, id),
|
|
1186
|
-
apiToken: this.authToken,
|
|
1187
|
-
customFetch: this.customFetch,
|
|
1188
|
-
requestId: requestId,
|
|
1189
|
-
});
|
|
1190
|
-
return isSuccess(response);
|
|
1191
|
-
}
|
|
1192
|
-
/**
|
|
1193
|
-
* Retrieves a list of shared labels.
|
|
1194
|
-
*
|
|
1195
|
-
* @param args - Optional parameters to filter shared labels.
|
|
1196
|
-
* @returns A promise that resolves to an array of shared labels.
|
|
1197
|
-
*/
|
|
1198
|
-
async getSharedLabels(args) {
|
|
1199
|
-
const { data: { results, nextCursor }, } = await request({
|
|
1200
|
-
httpMethod: 'GET',
|
|
1201
|
-
baseUri: this.syncApiBase,
|
|
1202
|
-
relativePath: ENDPOINT_REST_LABELS_SHARED,
|
|
1203
|
-
apiToken: this.authToken,
|
|
1204
|
-
customFetch: this.customFetch,
|
|
1205
|
-
payload: args,
|
|
1206
|
-
});
|
|
1207
|
-
return { results, nextCursor };
|
|
1208
|
-
}
|
|
1209
|
-
/**
|
|
1210
|
-
* Renames an existing shared label.
|
|
1211
|
-
*
|
|
1212
|
-
* @param args - Parameters for renaming the shared label, including the current and new name.
|
|
1213
|
-
* @returns A promise that resolves to `true` if successful.
|
|
1214
|
-
*/
|
|
1215
|
-
async renameSharedLabel(args) {
|
|
1216
|
-
const response = await request({
|
|
1217
|
-
httpMethod: 'POST',
|
|
1218
|
-
baseUri: this.syncApiBase,
|
|
1219
|
-
relativePath: ENDPOINT_REST_LABELS_SHARED_RENAME,
|
|
1220
|
-
apiToken: this.authToken,
|
|
1221
|
-
customFetch: this.customFetch,
|
|
1222
|
-
payload: args,
|
|
1223
|
-
});
|
|
1224
|
-
return isSuccess(response);
|
|
1225
|
-
}
|
|
1226
|
-
/**
|
|
1227
|
-
* Removes a shared label.
|
|
1228
|
-
*
|
|
1229
|
-
* @param args - Parameters for removing the shared label.
|
|
1230
|
-
* @returns A promise that resolves to `true` if successful.
|
|
1231
|
-
*/
|
|
1232
|
-
async removeSharedLabel(args) {
|
|
1233
|
-
const response = await request({
|
|
1234
|
-
httpMethod: 'POST',
|
|
1235
|
-
baseUri: this.syncApiBase,
|
|
1236
|
-
relativePath: ENDPOINT_REST_LABELS_SHARED_REMOVE,
|
|
1237
|
-
apiToken: this.authToken,
|
|
1238
|
-
customFetch: this.customFetch,
|
|
1239
|
-
payload: args,
|
|
1240
|
-
});
|
|
1241
|
-
return isSuccess(response);
|
|
1242
|
-
}
|
|
1243
|
-
/**
|
|
1244
|
-
* Retrieves all comments associated with a task or project.
|
|
1245
|
-
*
|
|
1246
|
-
* @param args - Parameters for retrieving comments, such as task ID or project ID.
|
|
1247
|
-
* @returns A promise that resolves to an array of comments.
|
|
1248
|
-
*/
|
|
1249
|
-
async getComments(args) {
|
|
1250
|
-
const { data: { results, nextCursor }, } = await request({
|
|
1251
|
-
httpMethod: 'GET',
|
|
1252
|
-
baseUri: this.syncApiBase,
|
|
1253
|
-
relativePath: ENDPOINT_REST_COMMENTS,
|
|
1254
|
-
apiToken: this.authToken,
|
|
1255
|
-
customFetch: this.customFetch,
|
|
1256
|
-
payload: args,
|
|
1257
|
-
});
|
|
1258
|
-
return {
|
|
1259
|
-
results: validateCommentArray(results),
|
|
1260
|
-
nextCursor,
|
|
1261
|
-
};
|
|
1262
|
-
}
|
|
1263
|
-
/**
|
|
1264
|
-
* Retrieves a specific comment by its ID.
|
|
1265
|
-
*
|
|
1266
|
-
* @param id - The unique identifier of the comment to retrieve.
|
|
1267
|
-
* @returns A promise that resolves to the requested comment.
|
|
1268
|
-
*/
|
|
1269
|
-
async getComment(id) {
|
|
1270
|
-
z.string().parse(id);
|
|
1271
|
-
const response = await request({
|
|
1272
|
-
httpMethod: 'GET',
|
|
1273
|
-
baseUri: this.syncApiBase,
|
|
1274
|
-
relativePath: generatePath(ENDPOINT_REST_COMMENTS, id),
|
|
1275
|
-
apiToken: this.authToken,
|
|
1276
|
-
customFetch: this.customFetch,
|
|
1277
|
-
});
|
|
1278
|
-
return validateComment(response.data);
|
|
1279
|
-
}
|
|
1280
|
-
/**
|
|
1281
|
-
* Adds a comment to a task or project.
|
|
1282
|
-
*
|
|
1283
|
-
* @param args - Parameters for creating the comment, such as content and the target task or project ID.
|
|
1284
|
-
* @param requestId - Optional custom identifier for the request.
|
|
1285
|
-
* @returns A promise that resolves to the created comment.
|
|
1286
|
-
*/
|
|
1287
|
-
async addComment(args, requestId) {
|
|
1288
|
-
const { uidsToNotify } = args, rest = __rest(args, ["uidsToNotify"]);
|
|
1289
|
-
const response = await request({
|
|
1290
|
-
httpMethod: 'POST',
|
|
1291
|
-
baseUri: this.syncApiBase,
|
|
1292
|
-
relativePath: ENDPOINT_REST_COMMENTS,
|
|
1293
|
-
apiToken: this.authToken,
|
|
1294
|
-
customFetch: this.customFetch,
|
|
1295
|
-
payload: Object.assign(Object.assign({}, rest), (uidsToNotify ? { uidsToNotify: uidsToNotify.join(',') } : {})),
|
|
1296
|
-
requestId: requestId,
|
|
1297
|
-
});
|
|
1298
|
-
return validateComment(response.data);
|
|
1299
|
-
}
|
|
1300
|
-
/**
|
|
1301
|
-
* Updates an existing comment by its ID.
|
|
1302
|
-
*
|
|
1303
|
-
* @param id - The unique identifier of the comment to update.
|
|
1304
|
-
* @param args - Update parameters such as new content.
|
|
1305
|
-
* @param requestId - Optional custom identifier for the request.
|
|
1306
|
-
* @returns A promise that resolves to the updated comment.
|
|
1307
|
-
*/
|
|
1308
|
-
async updateComment(id, args, requestId) {
|
|
1309
|
-
z.string().parse(id);
|
|
1310
|
-
const response = await request({
|
|
1311
|
-
httpMethod: 'POST',
|
|
1312
|
-
baseUri: this.syncApiBase,
|
|
1313
|
-
relativePath: generatePath(ENDPOINT_REST_COMMENTS, id),
|
|
1314
|
-
apiToken: this.authToken,
|
|
1315
|
-
customFetch: this.customFetch,
|
|
1316
|
-
payload: args,
|
|
1317
|
-
requestId: requestId,
|
|
1318
|
-
});
|
|
1319
|
-
return validateComment(response.data);
|
|
1320
|
-
}
|
|
1321
|
-
/**
|
|
1322
|
-
* Deletes a comment by its ID.
|
|
1323
|
-
*
|
|
1324
|
-
* @param id - The unique identifier of the comment to delete.
|
|
1325
|
-
* @param requestId - Optional custom identifier for the request.
|
|
1326
|
-
* @returns A promise that resolves to `true` if successful.
|
|
1327
|
-
*/
|
|
1328
|
-
async deleteComment(id, requestId) {
|
|
1329
|
-
z.string().parse(id);
|
|
1330
|
-
const response = await request({
|
|
1331
|
-
httpMethod: 'DELETE',
|
|
1332
|
-
baseUri: this.syncApiBase,
|
|
1333
|
-
relativePath: generatePath(ENDPOINT_REST_COMMENTS, id),
|
|
1334
|
-
apiToken: this.authToken,
|
|
1335
|
-
customFetch: this.customFetch,
|
|
1336
|
-
requestId: requestId,
|
|
1337
|
-
});
|
|
1338
|
-
return isSuccess(response);
|
|
1339
|
-
}
|
|
1340
|
-
/**
|
|
1341
|
-
* Retrieves a paginated list of time-based reminders.
|
|
1342
|
-
*
|
|
1343
|
-
* @param args - Optional parameters including task ID filter and pagination.
|
|
1344
|
-
* @returns A promise that resolves to a paginated list of reminders.
|
|
1345
|
-
*/
|
|
1346
|
-
async getReminders(args = {}) {
|
|
1347
|
-
const { data: { results, nextCursor }, } = await request({
|
|
1348
|
-
httpMethod: 'GET',
|
|
1349
|
-
baseUri: this.syncApiBase,
|
|
1350
|
-
relativePath: ENDPOINT_REST_REMINDERS,
|
|
1351
|
-
apiToken: this.authToken,
|
|
1352
|
-
customFetch: this.customFetch,
|
|
1353
|
-
payload: args,
|
|
1354
|
-
});
|
|
1355
|
-
return {
|
|
1356
|
-
results: validateReminderArray(results),
|
|
1357
|
-
nextCursor,
|
|
1358
|
-
};
|
|
1359
|
-
}
|
|
1360
|
-
/**
|
|
1361
|
-
* Retrieves a paginated list of location-based reminders.
|
|
1362
|
-
*
|
|
1363
|
-
* @param args - Optional parameters including task ID filter and pagination.
|
|
1364
|
-
* @returns A promise that resolves to a paginated list of location reminders.
|
|
1365
|
-
*/
|
|
1366
|
-
async getLocationReminders(args = {}) {
|
|
1367
|
-
const { data: { results, nextCursor }, } = await request({
|
|
1368
|
-
httpMethod: 'GET',
|
|
1369
|
-
baseUri: this.syncApiBase,
|
|
1370
|
-
relativePath: ENDPOINT_REST_LOCATION_REMINDERS,
|
|
1371
|
-
apiToken: this.authToken,
|
|
1372
|
-
customFetch: this.customFetch,
|
|
1373
|
-
payload: args,
|
|
1374
|
-
});
|
|
1375
|
-
return {
|
|
1376
|
-
results: validateLocationReminderArray(results),
|
|
1377
|
-
nextCursor,
|
|
1378
|
-
};
|
|
1379
|
-
}
|
|
1380
|
-
/**
|
|
1381
|
-
* Retrieves a time-based reminder by its ID.
|
|
1382
|
-
*
|
|
1383
|
-
* @param id - The unique identifier of the reminder to retrieve.
|
|
1384
|
-
* @returns A promise that resolves to the requested reminder.
|
|
1385
|
-
*/
|
|
1386
|
-
async getReminder(id) {
|
|
1387
|
-
ReminderIdSchema.parse(id);
|
|
1388
|
-
try {
|
|
1389
|
-
const response = await request({
|
|
1390
|
-
httpMethod: 'GET',
|
|
1391
|
-
baseUri: this.syncApiBase,
|
|
1392
|
-
relativePath: generatePath(ENDPOINT_REST_REMINDERS, id),
|
|
1393
|
-
apiToken: this.authToken,
|
|
1394
|
-
customFetch: this.customFetch,
|
|
1395
|
-
});
|
|
1396
|
-
return validateReminder(response.data);
|
|
1397
|
-
}
|
|
1398
|
-
catch (error) {
|
|
1399
|
-
if (!(error instanceof TodoistRequestError) || error.httpStatusCode !== 404) {
|
|
1400
|
-
throw error;
|
|
1401
|
-
}
|
|
1402
|
-
throw new TodoistArgumentError(`Reminder ${id} was not found on the time-based reminder endpoint. If this is a location reminder, use getLocationReminder instead.`);
|
|
1403
|
-
}
|
|
1404
|
-
}
|
|
1405
|
-
/**
|
|
1406
|
-
* Retrieves a location reminder by its ID.
|
|
1407
|
-
*
|
|
1408
|
-
* @param id - The unique identifier of the location reminder to retrieve.
|
|
1409
|
-
* @returns A promise that resolves to the requested reminder.
|
|
1410
|
-
*/
|
|
1411
|
-
async getLocationReminder(id) {
|
|
1412
|
-
ReminderIdSchema.parse(id);
|
|
1413
|
-
try {
|
|
1414
|
-
const response = await request({
|
|
1415
|
-
httpMethod: 'GET',
|
|
1416
|
-
baseUri: this.syncApiBase,
|
|
1417
|
-
relativePath: generatePath(ENDPOINT_REST_LOCATION_REMINDERS, id),
|
|
1418
|
-
apiToken: this.authToken,
|
|
1419
|
-
customFetch: this.customFetch,
|
|
1420
|
-
});
|
|
1421
|
-
return validateReminder(response.data);
|
|
1422
|
-
}
|
|
1423
|
-
catch (error) {
|
|
1424
|
-
if (!(error instanceof TodoistRequestError) || error.httpStatusCode !== 404) {
|
|
1425
|
-
throw error;
|
|
1426
|
-
}
|
|
1427
|
-
throw new TodoistArgumentError(`Location reminder ${id} was not found on the location reminder endpoint. If this is a time-based reminder, use getReminder instead.`);
|
|
1428
|
-
}
|
|
1429
|
-
}
|
|
1430
|
-
/**
|
|
1431
|
-
* Creates a time-based reminder for a task.
|
|
1432
|
-
*
|
|
1433
|
-
* @param args - Reminder creation parameters for relative or absolute reminders.
|
|
1434
|
-
* @param requestId - Optional custom identifier for the request.
|
|
1435
|
-
* @returns A promise that resolves to the created reminder.
|
|
1436
|
-
*/
|
|
1437
|
-
async addReminder(args, requestId) {
|
|
1438
|
-
const response = await request({
|
|
1439
|
-
httpMethod: 'POST',
|
|
1440
|
-
baseUri: this.syncApiBase,
|
|
1441
|
-
relativePath: ENDPOINT_REST_REMINDERS,
|
|
1442
|
-
apiToken: this.authToken,
|
|
1443
|
-
customFetch: this.customFetch,
|
|
1444
|
-
payload: args,
|
|
1445
|
-
requestId: requestId,
|
|
1446
|
-
});
|
|
1447
|
-
return validateReminder(response.data);
|
|
1448
|
-
}
|
|
1449
|
-
/**
|
|
1450
|
-
* Creates a location reminder for a task.
|
|
1451
|
-
*
|
|
1452
|
-
* @param args - Location reminder creation parameters.
|
|
1453
|
-
* @param requestId - Optional custom identifier for the request.
|
|
1454
|
-
* @returns A promise that resolves to the created reminder.
|
|
1455
|
-
*/
|
|
1456
|
-
async addLocationReminder(args, requestId) {
|
|
1457
|
-
const response = await request({
|
|
1458
|
-
httpMethod: 'POST',
|
|
1459
|
-
baseUri: this.syncApiBase,
|
|
1460
|
-
relativePath: ENDPOINT_REST_LOCATION_REMINDERS,
|
|
1461
|
-
apiToken: this.authToken,
|
|
1462
|
-
customFetch: this.customFetch,
|
|
1463
|
-
payload: Object.assign(Object.assign({}, args), { reminderType: 'location' }),
|
|
1464
|
-
requestId: requestId,
|
|
1465
|
-
});
|
|
1466
|
-
return validateReminder(response.data);
|
|
1467
|
-
}
|
|
1468
|
-
/**
|
|
1469
|
-
* Updates an existing time-based reminder.
|
|
1470
|
-
*
|
|
1471
|
-
* @param id - The unique identifier of the reminder to update.
|
|
1472
|
-
* @param args - Reminder update parameters.
|
|
1473
|
-
* @param requestId - Optional custom identifier for the request.
|
|
1474
|
-
* @returns A promise that resolves to the updated reminder.
|
|
1475
|
-
*/
|
|
1476
|
-
async updateReminder(id, args, requestId) {
|
|
1477
|
-
ReminderIdSchema.parse(id);
|
|
1478
|
-
const payload = UpdateReminderArgsSchema.parse(args);
|
|
1479
|
-
try {
|
|
1480
|
-
const response = await request({
|
|
1481
|
-
httpMethod: 'POST',
|
|
1482
|
-
baseUri: this.syncApiBase,
|
|
1483
|
-
relativePath: generatePath(ENDPOINT_REST_REMINDERS, id),
|
|
1484
|
-
apiToken: this.authToken,
|
|
1485
|
-
customFetch: this.customFetch,
|
|
1486
|
-
payload,
|
|
1487
|
-
requestId: requestId,
|
|
1488
|
-
});
|
|
1489
|
-
return validateReminder(response.data);
|
|
1490
|
-
}
|
|
1491
|
-
catch (error) {
|
|
1492
|
-
if (!(error instanceof TodoistRequestError) || error.httpStatusCode !== 404) {
|
|
1493
|
-
throw error;
|
|
1494
|
-
}
|
|
1495
|
-
throw new TodoistArgumentError(`Reminder ${id} was not found on the time-based reminder endpoint. If this is a location reminder, use updateLocationReminder instead.`);
|
|
1496
|
-
}
|
|
1497
|
-
}
|
|
1498
|
-
/**
|
|
1499
|
-
* Updates an existing location reminder.
|
|
1500
|
-
*
|
|
1501
|
-
* @param id - The unique identifier of the location reminder to update.
|
|
1502
|
-
* @param args - Location reminder update parameters.
|
|
1503
|
-
* @param requestId - Optional custom identifier for the request.
|
|
1504
|
-
* @returns A promise that resolves to the updated reminder.
|
|
1505
|
-
*/
|
|
1506
|
-
async updateLocationReminder(id, args, requestId) {
|
|
1507
|
-
ReminderIdSchema.parse(id);
|
|
1508
|
-
const payload = UpdateLocationReminderArgsSchema.parse(args);
|
|
1509
|
-
try {
|
|
1510
|
-
const response = await request({
|
|
1511
|
-
httpMethod: 'POST',
|
|
1512
|
-
baseUri: this.syncApiBase,
|
|
1513
|
-
relativePath: generatePath(ENDPOINT_REST_LOCATION_REMINDERS, id),
|
|
1514
|
-
apiToken: this.authToken,
|
|
1515
|
-
customFetch: this.customFetch,
|
|
1516
|
-
payload,
|
|
1517
|
-
requestId: requestId,
|
|
1518
|
-
});
|
|
1519
|
-
return validateReminder(response.data);
|
|
1520
|
-
}
|
|
1521
|
-
catch (error) {
|
|
1522
|
-
if (!(error instanceof TodoistRequestError) || error.httpStatusCode !== 404) {
|
|
1523
|
-
throw error;
|
|
1524
|
-
}
|
|
1525
|
-
throw new TodoistArgumentError(`Location reminder ${id} was not found on the location reminder endpoint. If this is a time-based reminder, use updateReminder instead.`);
|
|
1526
|
-
}
|
|
1527
|
-
}
|
|
1528
|
-
/**
|
|
1529
|
-
* Deletes a time-based reminder by its ID.
|
|
1530
|
-
*
|
|
1531
|
-
* @param id - The unique identifier of the reminder to delete.
|
|
1532
|
-
* @param requestId - Optional custom identifier for the request.
|
|
1533
|
-
* @returns A promise that resolves to `true` if successful.
|
|
1534
|
-
*/
|
|
1535
|
-
async deleteReminder(id, requestId) {
|
|
1536
|
-
ReminderIdSchema.parse(id);
|
|
1537
|
-
try {
|
|
1538
|
-
const response = await request({
|
|
1539
|
-
httpMethod: 'DELETE',
|
|
1540
|
-
baseUri: this.syncApiBase,
|
|
1541
|
-
relativePath: generatePath(ENDPOINT_REST_REMINDERS, id),
|
|
1542
|
-
apiToken: this.authToken,
|
|
1543
|
-
customFetch: this.customFetch,
|
|
1544
|
-
requestId: requestId,
|
|
1545
|
-
});
|
|
1546
|
-
return isSuccess(response);
|
|
1547
|
-
}
|
|
1548
|
-
catch (error) {
|
|
1549
|
-
if (!(error instanceof TodoistRequestError) || error.httpStatusCode !== 404) {
|
|
1550
|
-
throw error;
|
|
1551
|
-
}
|
|
1552
|
-
throw new TodoistArgumentError(`Reminder ${id} was not found on the time-based reminder endpoint. If this is a location reminder, use deleteLocationReminder instead.`);
|
|
1553
|
-
}
|
|
1554
|
-
}
|
|
1555
|
-
/**
|
|
1556
|
-
* Deletes a location reminder by its ID.
|
|
1557
|
-
*
|
|
1558
|
-
* @param id - The unique identifier of the location reminder to delete.
|
|
1559
|
-
* @param requestId - Optional custom identifier for the request.
|
|
1560
|
-
* @returns A promise that resolves to `true` if successful.
|
|
1561
|
-
*/
|
|
1562
|
-
async deleteLocationReminder(id, requestId) {
|
|
1563
|
-
ReminderIdSchema.parse(id);
|
|
1564
|
-
try {
|
|
1565
|
-
const response = await request({
|
|
1566
|
-
httpMethod: 'DELETE',
|
|
1567
|
-
baseUri: this.syncApiBase,
|
|
1568
|
-
relativePath: generatePath(ENDPOINT_REST_LOCATION_REMINDERS, id),
|
|
1569
|
-
apiToken: this.authToken,
|
|
1570
|
-
customFetch: this.customFetch,
|
|
1571
|
-
requestId: requestId,
|
|
1572
|
-
});
|
|
1573
|
-
return isSuccess(response);
|
|
1574
|
-
}
|
|
1575
|
-
catch (error) {
|
|
1576
|
-
if (!(error instanceof TodoistRequestError) || error.httpStatusCode !== 404) {
|
|
1577
|
-
throw error;
|
|
1578
|
-
}
|
|
1579
|
-
throw new TodoistArgumentError(`Location reminder ${id} was not found on the location reminder endpoint. If this is a time-based reminder, use deleteReminder instead.`);
|
|
1580
|
-
}
|
|
1581
|
-
}
|
|
1582
|
-
/**
|
|
1583
|
-
* Retrieves productivity stats for the authenticated user.
|
|
1584
|
-
*
|
|
1585
|
-
* @returns A promise that resolves to the productivity stats.
|
|
1586
|
-
*/
|
|
1587
|
-
async getProductivityStats() {
|
|
1588
|
-
const response = await request({
|
|
1589
|
-
httpMethod: 'GET',
|
|
1590
|
-
baseUri: this.syncApiBase,
|
|
1591
|
-
relativePath: ENDPOINT_REST_PRODUCTIVITY,
|
|
1592
|
-
apiToken: this.authToken,
|
|
1593
|
-
customFetch: this.customFetch,
|
|
1594
|
-
});
|
|
1595
|
-
return validateProductivityStats(response.data);
|
|
1596
|
-
}
|
|
1597
|
-
/**
|
|
1598
|
-
* Retrieves activity logs with optional filters.
|
|
1599
|
-
*
|
|
1600
|
-
* @param args - Optional filter parameters for activity logs.
|
|
1601
|
-
* @returns A promise that resolves to a paginated response of activity events.
|
|
1602
|
-
*/
|
|
1603
|
-
async getActivityLogs(args = {}) {
|
|
1604
|
-
// Convert Date objects to YYYY-MM-DD strings
|
|
1605
|
-
const dateFrom = args.dateFrom instanceof Date ? formatDateToYYYYMMDD(args.dateFrom) : args.dateFrom;
|
|
1606
|
-
const dateTo = args.dateTo instanceof Date ? formatDateToYYYYMMDD(args.dateTo) : args.dateTo;
|
|
1607
|
-
// Destructure out raw date, filter-type, and removed legacy fields so they don't leak into payload
|
|
1608
|
-
const _a = args, { dateFrom: _dateFrom, dateTo: _dateTo, objectEventTypes, objectType: _objectType, eventType: _eventType, since: _since, until: _until } = _a, rest = __rest(_a, ["dateFrom", "dateTo", "objectEventTypes", "objectType", "eventType", "since", "until"]);
|
|
1609
|
-
// Build normalized objectEventTypes for the API
|
|
1610
|
-
let normalizedObjectEventTypes;
|
|
1611
|
-
if (objectEventTypes !== undefined) {
|
|
1612
|
-
const arr = Array.isArray(objectEventTypes) ? objectEventTypes : [objectEventTypes];
|
|
1613
|
-
normalizedObjectEventTypes = arr.map(normalizeObjectEventTypeForApi);
|
|
1614
|
-
}
|
|
1615
|
-
const processedArgs = Object.assign(Object.assign(Object.assign(Object.assign({}, rest), (dateFrom !== undefined ? { dateFrom } : {})), (dateTo !== undefined ? { dateTo } : {})), (normalizedObjectEventTypes !== undefined
|
|
1616
|
-
? { objectEventTypes: normalizedObjectEventTypes }
|
|
1617
|
-
: {}));
|
|
1618
|
-
const { data: { results, nextCursor }, } = await request({
|
|
1619
|
-
httpMethod: 'GET',
|
|
1620
|
-
baseUri: this.syncApiBase,
|
|
1621
|
-
relativePath: ENDPOINT_REST_ACTIVITIES,
|
|
1622
|
-
apiToken: this.authToken,
|
|
1623
|
-
customFetch: this.customFetch,
|
|
1624
|
-
payload: processedArgs,
|
|
1625
|
-
});
|
|
1626
|
-
// Convert legacy API object types back to modern SDK types
|
|
1627
|
-
const normalizedResults = results.map((event) => {
|
|
1628
|
-
const normalizedType = denormalizeObjectTypeFromApi(event.objectType);
|
|
1629
|
-
return Object.assign(Object.assign({}, event), { objectType: normalizedType || event.objectType });
|
|
1630
|
-
});
|
|
1631
|
-
return {
|
|
1632
|
-
results: validateActivityEventArray(normalizedResults),
|
|
1633
|
-
nextCursor,
|
|
1634
|
-
};
|
|
1635
|
-
}
|
|
1636
|
-
/**
|
|
1637
|
-
* Uploads a file and returns attachment metadata.
|
|
1638
|
-
* This creates an upload record that can be referenced in tasks or comments.
|
|
1639
|
-
*
|
|
1640
|
-
* @param args - Upload parameters including file content, filename, and optional project ID.
|
|
1641
|
-
* @param requestId - Optional custom identifier for the request.
|
|
1642
|
-
* @returns A promise that resolves to the uploaded file's attachment metadata.
|
|
1643
|
-
*
|
|
1644
|
-
* @example
|
|
1645
|
-
* ```typescript
|
|
1646
|
-
* // Upload from a file path
|
|
1647
|
-
* const upload = await api.uploadFile({
|
|
1648
|
-
* file: '/path/to/document.pdf',
|
|
1649
|
-
* projectId: '12345'
|
|
1650
|
-
* })
|
|
1651
|
-
*
|
|
1652
|
-
* // Upload from a Buffer
|
|
1653
|
-
* const buffer = fs.readFileSync('/path/to/document.pdf')
|
|
1654
|
-
* const upload = await api.uploadFile({
|
|
1655
|
-
* file: buffer,
|
|
1656
|
-
* fileName: 'document.pdf', // Required for Buffer/Stream
|
|
1657
|
-
* projectId: '12345'
|
|
1658
|
-
* })
|
|
1659
|
-
*
|
|
1660
|
-
* // Use the returned fileUrl in a comment
|
|
1661
|
-
* await api.addComment({
|
|
1662
|
-
* content: 'See attached document',
|
|
1663
|
-
* taskId: '67890',
|
|
1664
|
-
* attachment: {
|
|
1665
|
-
* fileUrl: upload.fileUrl,
|
|
1666
|
-
* fileName: upload.fileName,
|
|
1667
|
-
* fileType: upload.fileType,
|
|
1668
|
-
* resourceType: upload.resourceType
|
|
1669
|
-
* }
|
|
1670
|
-
* })
|
|
1671
|
-
* ```
|
|
1672
|
-
*/
|
|
1673
|
-
async uploadFile(args, requestId) {
|
|
1674
|
-
const additionalFields = {};
|
|
1675
|
-
if (args.projectId) {
|
|
1676
|
-
additionalFields.project_id = args.projectId;
|
|
1677
|
-
}
|
|
1678
|
-
const data = await uploadMultipartFile({
|
|
1679
|
-
baseUrl: this.syncApiBase,
|
|
1680
|
-
authToken: this.authToken,
|
|
1681
|
-
endpoint: ENDPOINT_REST_UPLOADS,
|
|
1682
|
-
file: args.file,
|
|
1683
|
-
fileName: args.fileName,
|
|
1684
|
-
additionalFields: additionalFields,
|
|
1685
|
-
requestId: requestId,
|
|
1686
|
-
customFetch: this.customFetch,
|
|
1687
|
-
});
|
|
1688
|
-
return validateAttachment(data);
|
|
1689
|
-
}
|
|
1690
|
-
/**
|
|
1691
|
-
* Deletes an uploaded file by its URL.
|
|
1692
|
-
*
|
|
1693
|
-
* @param args - The file URL to delete.
|
|
1694
|
-
* @param requestId - Optional custom identifier for the request.
|
|
1695
|
-
* @returns A promise that resolves to `true` if deletion was successful.
|
|
1696
|
-
*
|
|
1697
|
-
* @example
|
|
1698
|
-
* ```typescript
|
|
1699
|
-
* await api.deleteUpload({
|
|
1700
|
-
* fileUrl: 'https://cdn.todoist.com/...'
|
|
1701
|
-
* })
|
|
1702
|
-
* ```
|
|
1703
|
-
*/
|
|
1704
|
-
async deleteUpload(args, requestId) {
|
|
1705
|
-
const response = await request({
|
|
1706
|
-
httpMethod: 'DELETE',
|
|
1707
|
-
baseUri: this.syncApiBase,
|
|
1708
|
-
relativePath: ENDPOINT_REST_UPLOADS,
|
|
1709
|
-
apiToken: this.authToken,
|
|
1710
|
-
customFetch: this.customFetch,
|
|
1711
|
-
payload: args,
|
|
1712
|
-
requestId: requestId,
|
|
1713
|
-
});
|
|
1714
|
-
return isSuccess(response);
|
|
1715
|
-
}
|
|
1716
|
-
/**
|
|
1717
|
-
* Fetches the content of a file attachment from a Todoist comment.
|
|
1718
|
-
*
|
|
1719
|
-
* Accepts either a Comment object (extracts the file URL from its attachment)
|
|
1720
|
-
* or a direct file URL string. Returns the raw Response object so the caller
|
|
1721
|
-
* can read the body in the appropriate format (.arrayBuffer(), .text(), etc.).
|
|
1722
|
-
*
|
|
1723
|
-
* @param commentOrUrl - A Comment object with a file attachment, or a file URL string.
|
|
1724
|
-
* @returns The raw fetch Response for the file content.
|
|
1725
|
-
* @throws Error if a Comment is provided without a file attachment or file URL.
|
|
1726
|
-
*
|
|
1727
|
-
* @example
|
|
1728
|
-
* ```typescript
|
|
1729
|
-
* // From a comment object
|
|
1730
|
-
* const comments = await api.getComments({ taskId: '12345' })
|
|
1731
|
-
* const comment = comments.results[0]
|
|
1732
|
-
* const response = await api.viewAttachment(comment)
|
|
1733
|
-
* const imageData = await response.arrayBuffer()
|
|
1734
|
-
*
|
|
1735
|
-
* // From a URL string
|
|
1736
|
-
* const response = await api.viewAttachment('https://files.todoist.com/...')
|
|
1737
|
-
* const text = await response.text()
|
|
1738
|
-
* ```
|
|
1739
|
-
*/
|
|
1740
|
-
async viewAttachment(commentOrUrl) {
|
|
1741
|
-
var _a;
|
|
1742
|
-
let fileUrl;
|
|
1743
|
-
if (typeof commentOrUrl === 'string') {
|
|
1744
|
-
fileUrl = commentOrUrl;
|
|
1745
|
-
}
|
|
1746
|
-
else {
|
|
1747
|
-
if (!((_a = commentOrUrl.fileAttachment) === null || _a === void 0 ? void 0 : _a.fileUrl)) {
|
|
1748
|
-
throw new Error('Comment does not have a file attachment');
|
|
1749
|
-
}
|
|
1750
|
-
fileUrl = commentOrUrl.fileAttachment.fileUrl;
|
|
1751
|
-
}
|
|
1752
|
-
// Validate the URL belongs to Todoist to prevent leaking the auth token
|
|
1753
|
-
const urlHostname = new URL(fileUrl).hostname;
|
|
1754
|
-
if (!urlHostname.endsWith('.todoist.com')) {
|
|
1755
|
-
throw new Error('Attachment URLs must be on a todoist.com domain');
|
|
1756
|
-
}
|
|
1757
|
-
const fetchOptions = {
|
|
1758
|
-
method: 'GET',
|
|
1759
|
-
headers: { Authorization: `Bearer ${this.authToken}` },
|
|
1760
|
-
};
|
|
1761
|
-
if (this.customFetch) {
|
|
1762
|
-
const response = await this.customFetch(fileUrl, fetchOptions);
|
|
1763
|
-
if (!response.ok) {
|
|
1764
|
-
throw new Error(`Failed to fetch attachment: ${response.status} ${response.statusText}`);
|
|
1765
|
-
}
|
|
1766
|
-
// Convert text to ArrayBuffer for custom fetch implementations that lack arrayBuffer()
|
|
1767
|
-
const text = await response.text();
|
|
1768
|
-
const buffer = new TextEncoder().encode(text).buffer;
|
|
1769
|
-
return {
|
|
1770
|
-
ok: response.ok,
|
|
1771
|
-
status: response.status,
|
|
1772
|
-
statusText: response.statusText,
|
|
1773
|
-
headers: response.headers,
|
|
1774
|
-
text: () => Promise.resolve(text),
|
|
1775
|
-
json: () => response.json(),
|
|
1776
|
-
arrayBuffer: () => Promise.resolve(buffer),
|
|
1777
|
-
};
|
|
1778
|
-
}
|
|
1779
|
-
const response = await fetch(fileUrl, fetchOptions);
|
|
1780
|
-
if (!response.ok) {
|
|
1781
|
-
throw new Error(`Failed to fetch attachment: ${response.status} ${response.statusText}`);
|
|
1782
|
-
}
|
|
1783
|
-
return {
|
|
1784
|
-
ok: response.ok,
|
|
1785
|
-
status: response.status,
|
|
1786
|
-
statusText: response.statusText,
|
|
1787
|
-
headers: headersToRecord(response.headers),
|
|
1788
|
-
text: () => response.text(),
|
|
1789
|
-
json: () => response.json(),
|
|
1790
|
-
arrayBuffer: () => response.arrayBuffer(),
|
|
1791
|
-
};
|
|
1792
|
-
}
|
|
1793
|
-
// ── Folders ──
|
|
1794
|
-
/**
|
|
1795
|
-
* Retrieves a paginated list of folders.
|
|
1796
|
-
*
|
|
1797
|
-
* @param args - Filter parameters such as workspace ID.
|
|
1798
|
-
* @returns A promise that resolves to a paginated response of folders.
|
|
1799
|
-
*/
|
|
1800
|
-
async getFolders(args) {
|
|
1801
|
-
const { data: { results, nextCursor }, } = await request({
|
|
1802
|
-
httpMethod: 'GET',
|
|
1803
|
-
baseUri: this.syncApiBase,
|
|
1804
|
-
relativePath: ENDPOINT_REST_FOLDERS,
|
|
1805
|
-
apiToken: this.authToken,
|
|
1806
|
-
customFetch: this.customFetch,
|
|
1807
|
-
payload: args,
|
|
1808
|
-
});
|
|
1809
|
-
return {
|
|
1810
|
-
results: validateFolderArray(results),
|
|
1811
|
-
nextCursor,
|
|
1812
|
-
};
|
|
1813
|
-
}
|
|
1814
|
-
/**
|
|
1815
|
-
* Retrieves a single folder by its ID.
|
|
1816
|
-
*
|
|
1817
|
-
* @param id - The unique identifier of the folder.
|
|
1818
|
-
* @returns A promise that resolves to the requested folder.
|
|
1819
|
-
*/
|
|
1820
|
-
async getFolder(id) {
|
|
1821
|
-
z.string().parse(id);
|
|
1822
|
-
const response = await request({
|
|
1823
|
-
httpMethod: 'GET',
|
|
1824
|
-
baseUri: this.syncApiBase,
|
|
1825
|
-
relativePath: generatePath(ENDPOINT_REST_FOLDERS, id),
|
|
1826
|
-
apiToken: this.authToken,
|
|
1827
|
-
customFetch: this.customFetch,
|
|
1828
|
-
});
|
|
1829
|
-
return validateFolder(response.data);
|
|
1830
|
-
}
|
|
1831
|
-
/**
|
|
1832
|
-
* Creates a new folder.
|
|
1833
|
-
*
|
|
1834
|
-
* @param args - Folder creation parameters including name and workspace ID.
|
|
1835
|
-
* @param requestId - Optional custom identifier for the request.
|
|
1836
|
-
* @returns A promise that resolves to the created folder.
|
|
1837
|
-
*/
|
|
1838
|
-
async addFolder(args, requestId) {
|
|
1839
|
-
const response = await request({
|
|
1840
|
-
httpMethod: 'POST',
|
|
1841
|
-
baseUri: this.syncApiBase,
|
|
1842
|
-
relativePath: ENDPOINT_REST_FOLDERS,
|
|
1843
|
-
apiToken: this.authToken,
|
|
1844
|
-
customFetch: this.customFetch,
|
|
1845
|
-
payload: args,
|
|
1846
|
-
requestId: requestId,
|
|
1847
|
-
});
|
|
1848
|
-
return validateFolder(response.data);
|
|
1849
|
-
}
|
|
1850
|
-
/**
|
|
1851
|
-
* Updates an existing folder by its ID.
|
|
1852
|
-
*
|
|
1853
|
-
* @param id - The unique identifier of the folder to update.
|
|
1854
|
-
* @param args - Update parameters such as name or default order.
|
|
1855
|
-
* @param requestId - Optional custom identifier for the request.
|
|
1856
|
-
* @returns A promise that resolves to the updated folder.
|
|
1857
|
-
*/
|
|
1858
|
-
async updateFolder(id, args, requestId) {
|
|
1859
|
-
z.string().parse(id);
|
|
1860
|
-
const response = await request({
|
|
1861
|
-
httpMethod: 'POST',
|
|
1862
|
-
baseUri: this.syncApiBase,
|
|
1863
|
-
relativePath: generatePath(ENDPOINT_REST_FOLDERS, id),
|
|
1864
|
-
apiToken: this.authToken,
|
|
1865
|
-
customFetch: this.customFetch,
|
|
1866
|
-
payload: args,
|
|
1867
|
-
requestId: requestId,
|
|
1868
|
-
});
|
|
1869
|
-
return validateFolder(response.data);
|
|
1870
|
-
}
|
|
1871
|
-
/**
|
|
1872
|
-
* Deletes a folder by its ID.
|
|
1873
|
-
*
|
|
1874
|
-
* @param id - The unique identifier of the folder to delete.
|
|
1875
|
-
* @param requestId - Optional custom identifier for the request.
|
|
1876
|
-
* @returns A promise that resolves to `true` if successful.
|
|
1877
|
-
*/
|
|
1878
|
-
async deleteFolder(id, requestId) {
|
|
1879
|
-
z.string().parse(id);
|
|
1880
|
-
const response = await request({
|
|
1881
|
-
httpMethod: 'DELETE',
|
|
1882
|
-
baseUri: this.syncApiBase,
|
|
1883
|
-
relativePath: generatePath(ENDPOINT_REST_FOLDERS, id),
|
|
1884
|
-
apiToken: this.authToken,
|
|
1885
|
-
customFetch: this.customFetch,
|
|
1886
|
-
requestId: requestId,
|
|
1887
|
-
});
|
|
1888
|
-
return isSuccess(response);
|
|
1889
|
-
}
|
|
1890
|
-
// ── Backups ──
|
|
1891
|
-
/**
|
|
1892
|
-
* Retrieves a list of available backups.
|
|
1893
|
-
*
|
|
1894
|
-
* @param args - Optional parameters including MFA token.
|
|
1895
|
-
* @returns A promise that resolves to an array of backups.
|
|
1896
|
-
*/
|
|
1897
|
-
async getBackups(args = {}) {
|
|
1898
|
-
const response = await request({
|
|
1899
|
-
httpMethod: 'GET',
|
|
1900
|
-
baseUri: this.syncApiBase,
|
|
1901
|
-
relativePath: ENDPOINT_REST_BACKUPS,
|
|
1902
|
-
apiToken: this.authToken,
|
|
1903
|
-
customFetch: this.customFetch,
|
|
1904
|
-
payload: args,
|
|
1905
|
-
});
|
|
1906
|
-
return validateBackupArray(response.data);
|
|
1907
|
-
}
|
|
1908
|
-
/**
|
|
1909
|
-
* Downloads a backup file as binary data.
|
|
1910
|
-
*
|
|
1911
|
-
* @param args - Arguments including the backup file URL (from getBackups).
|
|
1912
|
-
* @returns A promise that resolves to a response with binary data accessible via arrayBuffer().
|
|
1913
|
-
*/
|
|
1914
|
-
async downloadBackup(args) {
|
|
1915
|
-
const url = `${this.syncApiBase}${ENDPOINT_REST_BACKUPS_DOWNLOAD}?file=${encodeURIComponent(args.file)}`;
|
|
1916
|
-
const fetchOptions = {
|
|
1917
|
-
headers: { Authorization: `Bearer ${this.authToken}` },
|
|
1918
|
-
};
|
|
1919
|
-
if (this.customFetch) {
|
|
1920
|
-
const response = await this.customFetch(url, fetchOptions);
|
|
1921
|
-
if (!response.ok) {
|
|
1922
|
-
throw new Error(`Failed to download backup: ${response.status} ${response.statusText}`);
|
|
1923
|
-
}
|
|
1924
|
-
const text = await response.text();
|
|
1925
|
-
const buffer = new TextEncoder().encode(text).buffer;
|
|
1926
|
-
return {
|
|
1927
|
-
ok: response.ok,
|
|
1928
|
-
status: response.status,
|
|
1929
|
-
statusText: response.statusText,
|
|
1930
|
-
headers: response.headers,
|
|
1931
|
-
text: () => Promise.resolve(text),
|
|
1932
|
-
json: () => response.json(),
|
|
1933
|
-
arrayBuffer: () => Promise.resolve(buffer),
|
|
1934
|
-
};
|
|
1935
|
-
}
|
|
1936
|
-
const response = await fetch(url, fetchOptions);
|
|
1937
|
-
if (!response.ok) {
|
|
1938
|
-
throw new Error(`Failed to download backup: ${response.status} ${response.statusText}`);
|
|
1939
|
-
}
|
|
1940
|
-
return {
|
|
1941
|
-
ok: response.ok,
|
|
1942
|
-
status: response.status,
|
|
1943
|
-
statusText: response.statusText,
|
|
1944
|
-
headers: headersToRecord(response.headers),
|
|
1945
|
-
text: () => response.text(),
|
|
1946
|
-
json: () => response.json(),
|
|
1947
|
-
arrayBuffer: () => response.arrayBuffer(),
|
|
1948
|
-
};
|
|
1949
|
-
}
|
|
1950
|
-
// ── Emails ──
|
|
1951
|
-
/**
|
|
1952
|
-
* Gets or creates an email forwarding address for an object.
|
|
1953
|
-
*
|
|
1954
|
-
* @param args - Arguments including object type and ID.
|
|
1955
|
-
* @param requestId - Optional custom identifier for the request.
|
|
1956
|
-
* @returns A promise that resolves to the email address.
|
|
1957
|
-
*/
|
|
1958
|
-
async getOrCreateEmailForwarding(args, requestId) {
|
|
1959
|
-
const { data } = await request({
|
|
1960
|
-
httpMethod: 'PUT',
|
|
1961
|
-
baseUri: this.syncApiBase,
|
|
1962
|
-
relativePath: ENDPOINT_REST_EMAILS,
|
|
1963
|
-
apiToken: this.authToken,
|
|
1964
|
-
customFetch: this.customFetch,
|
|
1965
|
-
payload: args,
|
|
1966
|
-
requestId: requestId,
|
|
1967
|
-
});
|
|
1968
|
-
return data;
|
|
1969
|
-
}
|
|
1970
|
-
/**
|
|
1971
|
-
* Disables email forwarding for an object.
|
|
1972
|
-
*
|
|
1973
|
-
* @param args - Arguments including object type and ID.
|
|
1974
|
-
* @param requestId - Optional custom identifier for the request.
|
|
1975
|
-
* @returns A promise that resolves to `true` if successful.
|
|
1976
|
-
*/
|
|
1977
|
-
async disableEmailForwarding(args, requestId) {
|
|
1978
|
-
const queryParams = new URLSearchParams({
|
|
1979
|
-
obj_type: args.objType,
|
|
1980
|
-
obj_id: args.objId,
|
|
1981
|
-
});
|
|
1982
|
-
const response = await request({
|
|
1983
|
-
httpMethod: 'DELETE',
|
|
1984
|
-
baseUri: this.syncApiBase,
|
|
1985
|
-
relativePath: `${ENDPOINT_REST_EMAILS}?${queryParams.toString()}`,
|
|
1986
|
-
apiToken: this.authToken,
|
|
1987
|
-
customFetch: this.customFetch,
|
|
1988
|
-
requestId: requestId,
|
|
1989
|
-
});
|
|
1990
|
-
return isSuccess(response);
|
|
1991
|
-
}
|
|
1992
|
-
// ── ID Mappings ──
|
|
1993
|
-
/**
|
|
1994
|
-
* Retrieves ID mappings between old and new IDs.
|
|
1995
|
-
*
|
|
1996
|
-
* @param args - Arguments including object type and IDs to look up.
|
|
1997
|
-
* @returns A promise that resolves to an array of ID mappings.
|
|
1998
|
-
*/
|
|
1999
|
-
async getIdMappings(args) {
|
|
2000
|
-
const response = await request({
|
|
2001
|
-
httpMethod: 'GET',
|
|
2002
|
-
baseUri: this.syncApiBase,
|
|
2003
|
-
relativePath: generatePath(ENDPOINT_REST_ID_MAPPINGS, args.objName, args.objIds.join(',')),
|
|
2004
|
-
apiToken: this.authToken,
|
|
2005
|
-
customFetch: this.customFetch,
|
|
2006
|
-
});
|
|
2007
|
-
return validateIdMappingArray(response.data);
|
|
2008
|
-
}
|
|
2009
|
-
/**
|
|
2010
|
-
* Retrieves moved IDs for objects that have been migrated.
|
|
2011
|
-
*
|
|
2012
|
-
* @param args - Arguments including object type and optional old IDs to look up.
|
|
2013
|
-
* @returns A promise that resolves to an array of moved ID pairs.
|
|
2014
|
-
*/
|
|
2015
|
-
async getMovedIds(args) {
|
|
2016
|
-
const response = await request({
|
|
2017
|
-
httpMethod: 'GET',
|
|
2018
|
-
baseUri: this.syncApiBase,
|
|
2019
|
-
relativePath: generatePath(ENDPOINT_REST_MOVED_IDS, args.objName),
|
|
2020
|
-
apiToken: this.authToken,
|
|
2021
|
-
customFetch: this.customFetch,
|
|
2022
|
-
payload: args.oldIds ? { oldIds: args.oldIds.join(',') } : undefined,
|
|
2023
|
-
});
|
|
2024
|
-
return validateMovedIdArray(response.data);
|
|
2025
|
-
}
|
|
2026
|
-
// ── Templates ──
|
|
2027
|
-
/**
|
|
2028
|
-
* Exports a project as a template file (CSV format).
|
|
2029
|
-
*
|
|
2030
|
-
* @param args - Arguments including project ID and optional date format preference.
|
|
2031
|
-
* @returns A promise that resolves to the template file content as a string.
|
|
2032
|
-
*/
|
|
2033
|
-
async exportTemplateAsFile(args) {
|
|
2034
|
-
const response = await request({
|
|
2035
|
-
httpMethod: 'GET',
|
|
2036
|
-
baseUri: this.syncApiBase,
|
|
2037
|
-
relativePath: ENDPOINT_REST_TEMPLATES_FILE,
|
|
2038
|
-
apiToken: this.authToken,
|
|
2039
|
-
customFetch: this.customFetch,
|
|
2040
|
-
payload: args,
|
|
2041
|
-
});
|
|
2042
|
-
return response.data;
|
|
2043
|
-
}
|
|
2044
|
-
/**
|
|
2045
|
-
* Exports a project as a template URL.
|
|
2046
|
-
*
|
|
2047
|
-
* @param args - Arguments including project ID and optional date format preference.
|
|
2048
|
-
* @returns A promise that resolves to the file name and URL.
|
|
2049
|
-
*/
|
|
2050
|
-
async exportTemplateAsUrl(args) {
|
|
2051
|
-
const { data } = await request({
|
|
2052
|
-
httpMethod: 'GET',
|
|
2053
|
-
baseUri: this.syncApiBase,
|
|
2054
|
-
relativePath: ENDPOINT_REST_TEMPLATES_URL,
|
|
2055
|
-
apiToken: this.authToken,
|
|
2056
|
-
customFetch: this.customFetch,
|
|
2057
|
-
payload: args,
|
|
2058
|
-
});
|
|
2059
|
-
return data;
|
|
2060
|
-
}
|
|
2061
|
-
/**
|
|
2062
|
-
* Creates a new project from a template file.
|
|
2063
|
-
*
|
|
2064
|
-
* @param args - Arguments including project name, template file, and optional workspace ID.
|
|
2065
|
-
* @param requestId - Optional custom identifier for the request.
|
|
2066
|
-
* @returns A promise that resolves to the created project data.
|
|
2067
|
-
*/
|
|
2068
|
-
async createProjectFromTemplate(args, requestId) {
|
|
2069
|
-
const { file, fileName, name, workspaceId } = args;
|
|
2070
|
-
const additionalFields = { name };
|
|
2071
|
-
if (workspaceId !== undefined && workspaceId !== null) {
|
|
2072
|
-
additionalFields.workspace_id = workspaceId;
|
|
2073
|
-
}
|
|
2074
|
-
const data = await uploadMultipartFile({
|
|
2075
|
-
baseUrl: this.syncApiBase,
|
|
2076
|
-
authToken: this.authToken,
|
|
2077
|
-
endpoint: ENDPOINT_REST_TEMPLATES_CREATE_FROM_FILE,
|
|
2078
|
-
file,
|
|
2079
|
-
fileName,
|
|
2080
|
-
additionalFields,
|
|
2081
|
-
customFetch: this.customFetch,
|
|
2082
|
-
requestId,
|
|
2083
|
-
});
|
|
2084
|
-
return this.validateTemplateResponse(camelCaseKeys(data));
|
|
2085
|
-
}
|
|
2086
|
-
/**
|
|
2087
|
-
* Imports a template file into an existing project.
|
|
2088
|
-
*
|
|
2089
|
-
* @param args - Arguments including project ID and template file.
|
|
2090
|
-
* @param requestId - Optional custom identifier for the request.
|
|
2091
|
-
* @returns A promise that resolves to the import result.
|
|
2092
|
-
*/
|
|
2093
|
-
async importTemplateIntoProject(args, requestId) {
|
|
2094
|
-
const { file, fileName, projectId } = args;
|
|
2095
|
-
const data = await uploadMultipartFile({
|
|
2096
|
-
baseUrl: this.syncApiBase,
|
|
2097
|
-
authToken: this.authToken,
|
|
2098
|
-
endpoint: ENDPOINT_REST_TEMPLATES_IMPORT_FROM_FILE,
|
|
2099
|
-
file,
|
|
2100
|
-
fileName,
|
|
2101
|
-
additionalFields: { project_id: projectId },
|
|
2102
|
-
customFetch: this.customFetch,
|
|
2103
|
-
requestId,
|
|
2104
|
-
});
|
|
2105
|
-
return this.validateTemplateResponse(camelCaseKeys(data));
|
|
2106
|
-
}
|
|
2107
|
-
/**
|
|
2108
|
-
* Imports a template by ID into an existing project.
|
|
2109
|
-
*
|
|
2110
|
-
* @param args - Arguments including project ID, template ID, and optional locale.
|
|
2111
|
-
* @param requestId - Optional custom identifier for the request.
|
|
2112
|
-
* @returns A promise that resolves to the import result.
|
|
2113
|
-
*/
|
|
2114
|
-
async importTemplateFromId(args, requestId) {
|
|
2115
|
-
const { data } = await request({
|
|
2116
|
-
httpMethod: 'POST',
|
|
2117
|
-
baseUri: this.syncApiBase,
|
|
2118
|
-
relativePath: ENDPOINT_REST_TEMPLATES_IMPORT_FROM_ID,
|
|
2119
|
-
apiToken: this.authToken,
|
|
2120
|
-
customFetch: this.customFetch,
|
|
2121
|
-
payload: args,
|
|
2122
|
-
requestId: requestId,
|
|
2123
|
-
});
|
|
2124
|
-
return this.validateTemplateResponse(data);
|
|
2125
|
-
}
|
|
2126
|
-
validateTemplateResponse(data) {
|
|
2127
|
-
var _a, _b, _c, _d;
|
|
2128
|
-
return Object.assign(Object.assign({}, data), { projects: validateProjectArray((_a = data.projects) !== null && _a !== void 0 ? _a : []), sections: validateSectionArray((_b = data.sections) !== null && _b !== void 0 ? _b : []), tasks: validateTaskArray((_c = data.tasks) !== null && _c !== void 0 ? _c : []), comments: validateCommentArray((_d = data.comments) !== null && _d !== void 0 ? _d : []) });
|
|
2129
|
-
}
|
|
2130
|
-
/* Workspace methods */
|
|
2131
|
-
/**
|
|
2132
|
-
* Gets pending invitations for a workspace.
|
|
2133
|
-
*
|
|
2134
|
-
* @param args - Arguments including workspace ID.
|
|
2135
|
-
* @param requestId - Optional request ID for idempotency.
|
|
2136
|
-
* @returns Array of email addresses with pending invitations.
|
|
2137
|
-
*/
|
|
2138
|
-
async getWorkspaceInvitations(args, requestId) {
|
|
2139
|
-
const response = await request({
|
|
2140
|
-
httpMethod: 'GET',
|
|
2141
|
-
baseUri: this.syncApiBase,
|
|
2142
|
-
relativePath: ENDPOINT_WORKSPACE_INVITATIONS,
|
|
2143
|
-
apiToken: this.authToken,
|
|
2144
|
-
customFetch: this.customFetch,
|
|
2145
|
-
payload: { workspace_id: args.workspaceId },
|
|
2146
|
-
requestId: requestId,
|
|
2147
|
-
});
|
|
2148
|
-
return response.data;
|
|
2149
|
-
}
|
|
2150
|
-
/**
|
|
2151
|
-
* Gets all workspace invitations (admin only).
|
|
2152
|
-
*
|
|
2153
|
-
* @param requestId - Optional request ID for idempotency.
|
|
2154
|
-
* @returns Array of email addresses with pending invitations.
|
|
2155
|
-
*/
|
|
2156
|
-
async getAllWorkspaceInvitations(args = {}, requestId) {
|
|
2157
|
-
const queryParams = {};
|
|
2158
|
-
if (args.workspaceId) {
|
|
2159
|
-
queryParams.workspace_id = args.workspaceId;
|
|
2160
|
-
}
|
|
2161
|
-
const response = await request({
|
|
2162
|
-
httpMethod: 'GET',
|
|
2163
|
-
baseUri: this.syncApiBase,
|
|
2164
|
-
relativePath: ENDPOINT_WORKSPACE_INVITATIONS_ALL,
|
|
2165
|
-
apiToken: this.authToken,
|
|
2166
|
-
customFetch: this.customFetch,
|
|
2167
|
-
payload: queryParams,
|
|
2168
|
-
requestId: requestId,
|
|
2169
|
-
});
|
|
2170
|
-
return validateWorkspaceInvitationArray(response.data);
|
|
2171
|
-
}
|
|
2172
|
-
/**
|
|
2173
|
-
* Deletes a workspace invitation (admin only).
|
|
2174
|
-
*
|
|
2175
|
-
* @param args - Arguments including workspace ID and user email.
|
|
2176
|
-
* @param requestId - Optional request ID for idempotency.
|
|
2177
|
-
* @returns The deleted invitation.
|
|
2178
|
-
*/
|
|
2179
|
-
async deleteWorkspaceInvitation(args, requestId) {
|
|
2180
|
-
const response = await request({
|
|
2181
|
-
httpMethod: 'POST',
|
|
2182
|
-
baseUri: this.syncApiBase,
|
|
2183
|
-
relativePath: ENDPOINT_WORKSPACE_INVITATIONS_DELETE,
|
|
2184
|
-
apiToken: this.authToken,
|
|
2185
|
-
customFetch: this.customFetch,
|
|
2186
|
-
payload: {
|
|
2187
|
-
workspace_id: args.workspaceId,
|
|
2188
|
-
user_email: args.userEmail,
|
|
2189
|
-
},
|
|
2190
|
-
requestId: requestId,
|
|
2191
|
-
});
|
|
2192
|
-
return validateWorkspaceInvitation(response.data);
|
|
2193
|
-
}
|
|
2194
|
-
/**
|
|
2195
|
-
* Accepts a workspace invitation.
|
|
2196
|
-
*
|
|
2197
|
-
* @param args - Arguments including invite code.
|
|
2198
|
-
* @param requestId - Optional request ID for idempotency.
|
|
2199
|
-
* @returns The accepted invitation.
|
|
2200
|
-
*/
|
|
2201
|
-
async acceptWorkspaceInvitation(args, requestId) {
|
|
2202
|
-
const response = await request({
|
|
2203
|
-
httpMethod: 'PUT',
|
|
2204
|
-
baseUri: this.syncApiBase,
|
|
2205
|
-
relativePath: getWorkspaceInvitationAcceptEndpoint(args.inviteCode),
|
|
2206
|
-
apiToken: this.authToken,
|
|
2207
|
-
customFetch: this.customFetch,
|
|
2208
|
-
requestId: requestId,
|
|
2209
|
-
});
|
|
2210
|
-
return validateWorkspaceInvitation(response.data);
|
|
2211
|
-
}
|
|
2212
|
-
/**
|
|
2213
|
-
* Rejects a workspace invitation.
|
|
2214
|
-
*
|
|
2215
|
-
* @param args - Arguments including invite code.
|
|
2216
|
-
* @param requestId - Optional request ID for idempotency.
|
|
2217
|
-
* @returns The rejected invitation.
|
|
2218
|
-
*/
|
|
2219
|
-
async rejectWorkspaceInvitation(args, requestId) {
|
|
2220
|
-
const response = await request({
|
|
2221
|
-
httpMethod: 'PUT',
|
|
2222
|
-
baseUri: this.syncApiBase,
|
|
2223
|
-
relativePath: getWorkspaceInvitationRejectEndpoint(args.inviteCode),
|
|
2224
|
-
apiToken: this.authToken,
|
|
2225
|
-
customFetch: this.customFetch,
|
|
2226
|
-
requestId: requestId,
|
|
2227
|
-
});
|
|
2228
|
-
return validateWorkspaceInvitation(response.data);
|
|
2229
|
-
}
|
|
2230
|
-
/**
|
|
2231
|
-
* Joins a workspace via invitation link or domain auto-join.
|
|
2232
|
-
*
|
|
2233
|
-
* @param args - Arguments including invite code or workspace ID.
|
|
2234
|
-
* @param requestId - Optional request ID for idempotency.
|
|
2235
|
-
* @returns Workspace user information.
|
|
2236
|
-
*/
|
|
2237
|
-
async joinWorkspace(args, requestId) {
|
|
2238
|
-
const response = await request({
|
|
2239
|
-
httpMethod: 'POST',
|
|
2240
|
-
baseUri: this.syncApiBase,
|
|
2241
|
-
relativePath: ENDPOINT_WORKSPACE_JOIN,
|
|
2242
|
-
apiToken: this.authToken,
|
|
2243
|
-
customFetch: this.customFetch,
|
|
2244
|
-
payload: {
|
|
2245
|
-
invite_code: args.inviteCode,
|
|
2246
|
-
workspace_id: args.workspaceId,
|
|
2247
|
-
},
|
|
2248
|
-
requestId: requestId,
|
|
2249
|
-
});
|
|
2250
|
-
return validateJoinWorkspaceResult(response.data);
|
|
2251
|
-
}
|
|
2252
|
-
/**
|
|
2253
|
-
* Uploads or updates a workspace logo.
|
|
2254
|
-
*
|
|
2255
|
-
* @param args - Arguments including workspace ID, file, and options.
|
|
2256
|
-
* @param requestId - Optional request ID for idempotency.
|
|
2257
|
-
* @returns Logo information or null if deleted.
|
|
2258
|
-
*/
|
|
2259
|
-
async uploadWorkspaceLogo(args, requestId) {
|
|
2260
|
-
if (args.delete) {
|
|
2261
|
-
// Delete logo
|
|
2262
|
-
const data = await uploadMultipartFile({
|
|
2263
|
-
baseUrl: this.syncApiBase,
|
|
2264
|
-
authToken: this.authToken,
|
|
2265
|
-
endpoint: ENDPOINT_WORKSPACE_LOGO,
|
|
2266
|
-
file: Buffer.alloc(0), // Empty buffer for delete
|
|
2267
|
-
fileName: 'delete',
|
|
2268
|
-
additionalFields: {
|
|
2269
|
-
workspace_id: args.workspaceId,
|
|
2270
|
-
delete: true,
|
|
2271
|
-
},
|
|
2272
|
-
requestId: requestId,
|
|
2273
|
-
customFetch: this.customFetch,
|
|
2274
|
-
});
|
|
2275
|
-
return data;
|
|
2276
|
-
}
|
|
2277
|
-
if (!args.file) {
|
|
2278
|
-
throw new Error('file is required when not deleting logo');
|
|
2279
|
-
}
|
|
2280
|
-
// Validate buffer is not empty if it's a Buffer
|
|
2281
|
-
if (Buffer.isBuffer(args.file) && args.file.length === 0) {
|
|
2282
|
-
throw new Error('Cannot upload empty image file');
|
|
2283
|
-
}
|
|
2284
|
-
const additionalFields = {
|
|
2285
|
-
workspace_id: args.workspaceId,
|
|
2286
|
-
};
|
|
2287
|
-
const data = await uploadMultipartFile({
|
|
2288
|
-
baseUrl: this.syncApiBase,
|
|
2289
|
-
authToken: this.authToken,
|
|
2290
|
-
endpoint: ENDPOINT_WORKSPACE_LOGO,
|
|
2291
|
-
file: args.file,
|
|
2292
|
-
fileName: args.fileName,
|
|
2293
|
-
additionalFields: additionalFields,
|
|
2294
|
-
requestId: requestId,
|
|
2295
|
-
customFetch: this.customFetch,
|
|
2296
|
-
});
|
|
2297
|
-
return data;
|
|
2298
|
-
}
|
|
2299
|
-
/**
|
|
2300
|
-
* Gets workspace plan and billing details.
|
|
2301
|
-
*
|
|
2302
|
-
* @param args - Arguments including workspace ID.
|
|
2303
|
-
* @param requestId - Optional request ID for idempotency.
|
|
2304
|
-
* @returns Workspace plan details.
|
|
2305
|
-
*/
|
|
2306
|
-
async getWorkspacePlanDetails(args, requestId) {
|
|
2307
|
-
const response = await request({
|
|
2308
|
-
httpMethod: 'GET',
|
|
2309
|
-
baseUri: this.syncApiBase,
|
|
2310
|
-
relativePath: ENDPOINT_WORKSPACE_PLAN_DETAILS,
|
|
2311
|
-
apiToken: this.authToken,
|
|
2312
|
-
customFetch: this.customFetch,
|
|
2313
|
-
payload: { workspace_id: args.workspaceId },
|
|
2314
|
-
requestId: requestId,
|
|
2315
|
-
});
|
|
2316
|
-
return validateWorkspacePlanDetails(response.data);
|
|
2317
|
-
}
|
|
2318
|
-
/**
|
|
2319
|
-
* Gets workspace users with pagination.
|
|
2320
|
-
*
|
|
2321
|
-
* @param args - Arguments including optional workspace ID, cursor, and limit.
|
|
2322
|
-
* @param requestId - Optional request ID for idempotency.
|
|
2323
|
-
* @returns Paginated list of workspace users.
|
|
2324
|
-
*/
|
|
2325
|
-
async getWorkspaceUsers(args = {}, requestId) {
|
|
2326
|
-
const queryParams = {};
|
|
2327
|
-
if (args.workspaceId !== undefined && args.workspaceId !== null) {
|
|
2328
|
-
queryParams.workspace_id = args.workspaceId;
|
|
2329
|
-
}
|
|
2330
|
-
if (args.cursor) {
|
|
2331
|
-
queryParams.cursor = args.cursor;
|
|
2332
|
-
}
|
|
2333
|
-
if (args.limit) {
|
|
2334
|
-
queryParams.limit = args.limit;
|
|
2335
|
-
}
|
|
2336
|
-
const response = await request({
|
|
2337
|
-
httpMethod: 'GET',
|
|
2338
|
-
baseUri: this.syncApiBase,
|
|
2339
|
-
relativePath: ENDPOINT_WORKSPACE_USERS,
|
|
2340
|
-
apiToken: this.authToken,
|
|
2341
|
-
customFetch: this.customFetch,
|
|
2342
|
-
payload: queryParams,
|
|
2343
|
-
requestId: requestId,
|
|
2344
|
-
});
|
|
2345
|
-
return {
|
|
2346
|
-
hasMore: response.data.hasMore || false,
|
|
2347
|
-
nextCursor: response.data.nextCursor,
|
|
2348
|
-
workspaceUsers: validateWorkspaceUserArray(response.data.workspaceUsers || []),
|
|
2349
|
-
};
|
|
2350
|
-
}
|
|
2351
|
-
/**
|
|
2352
|
-
* Retrieves all workspaces for the authenticated user.
|
|
2353
|
-
*
|
|
2354
|
-
* @param requestId - Optional custom identifier for the request.
|
|
2355
|
-
* @returns A promise that resolves to an array of workspaces.
|
|
2356
|
-
*
|
|
2357
|
-
* @example
|
|
2358
|
-
* ```typescript
|
|
2359
|
-
* const workspaces = await api.getWorkspaces()
|
|
2360
|
-
* workspaces.forEach(workspace => {
|
|
2361
|
-
* console.log(`${workspace.name} (${workspace.plan}) - Role: ${workspace.role}`)
|
|
2362
|
-
* })
|
|
2363
|
-
* ```
|
|
2364
|
-
*/
|
|
2365
|
-
async getWorkspaces(requestId) {
|
|
2366
|
-
const response = await request({
|
|
2367
|
-
httpMethod: 'GET',
|
|
2368
|
-
baseUri: this.syncApiBase,
|
|
2369
|
-
relativePath: ENDPOINT_REST_WORKSPACES,
|
|
2370
|
-
apiToken: this.authToken,
|
|
2371
|
-
customFetch: this.customFetch,
|
|
2372
|
-
requestId: requestId,
|
|
2373
|
-
});
|
|
2374
|
-
return validateWorkspaceArray(response.data);
|
|
2375
|
-
}
|
|
2376
|
-
/**
|
|
2377
|
-
* Retrieves a workspace by its ID.
|
|
2378
|
-
*
|
|
2379
|
-
* @param id - The unique identifier of the workspace.
|
|
2380
|
-
* @param requestId - Optional custom identifier for the request.
|
|
2381
|
-
* @returns A promise that resolves to the requested workspace.
|
|
2382
|
-
*/
|
|
2383
|
-
async getWorkspace(id, requestId) {
|
|
2384
|
-
z.string().parse(id);
|
|
2385
|
-
const response = await request({
|
|
2386
|
-
httpMethod: 'GET',
|
|
2387
|
-
baseUri: this.syncApiBase,
|
|
2388
|
-
relativePath: generatePath(ENDPOINT_REST_WORKSPACES, id),
|
|
2389
|
-
apiToken: this.authToken,
|
|
2390
|
-
customFetch: this.customFetch,
|
|
2391
|
-
requestId: requestId,
|
|
2392
|
-
});
|
|
2393
|
-
return validateWorkspace(response.data);
|
|
2394
|
-
}
|
|
2395
|
-
/**
|
|
2396
|
-
* Creates a new workspace.
|
|
2397
|
-
*
|
|
2398
|
-
* @param args - The arguments for creating the workspace.
|
|
2399
|
-
* @param requestId - Optional custom identifier for the request.
|
|
2400
|
-
* @returns A promise that resolves to the created workspace.
|
|
2401
|
-
*/
|
|
2402
|
-
async addWorkspace(args, requestId) {
|
|
2403
|
-
const response = await request({
|
|
2404
|
-
httpMethod: 'POST',
|
|
2405
|
-
baseUri: this.syncApiBase,
|
|
2406
|
-
relativePath: ENDPOINT_REST_WORKSPACES,
|
|
2407
|
-
apiToken: this.authToken,
|
|
2408
|
-
customFetch: this.customFetch,
|
|
2409
|
-
payload: args,
|
|
2410
|
-
requestId: requestId,
|
|
2411
|
-
});
|
|
2412
|
-
return validateWorkspace(response.data);
|
|
2413
|
-
}
|
|
2414
|
-
/**
|
|
2415
|
-
* Updates an existing workspace.
|
|
2416
|
-
*
|
|
2417
|
-
* @param id - The unique identifier of the workspace to update.
|
|
2418
|
-
* @param args - The arguments for updating the workspace.
|
|
2419
|
-
* @param requestId - Optional custom identifier for the request.
|
|
2420
|
-
* @returns A promise that resolves to the updated workspace.
|
|
2421
|
-
*/
|
|
2422
|
-
async updateWorkspace(id, args, requestId) {
|
|
2423
|
-
z.string().parse(id);
|
|
2424
|
-
const response = await request({
|
|
2425
|
-
httpMethod: 'POST',
|
|
2426
|
-
baseUri: this.syncApiBase,
|
|
2427
|
-
relativePath: generatePath(ENDPOINT_REST_WORKSPACES, id),
|
|
2428
|
-
apiToken: this.authToken,
|
|
2429
|
-
customFetch: this.customFetch,
|
|
2430
|
-
payload: args,
|
|
2431
|
-
requestId: requestId,
|
|
2432
|
-
});
|
|
2433
|
-
return validateWorkspace(response.data);
|
|
2434
|
-
}
|
|
2435
|
-
/**
|
|
2436
|
-
* Deletes a workspace by its ID.
|
|
2437
|
-
*
|
|
2438
|
-
* @param id - The unique identifier of the workspace to delete.
|
|
2439
|
-
* @param requestId - Optional custom identifier for the request.
|
|
2440
|
-
* @returns A promise that resolves to `true` if successful.
|
|
2441
|
-
*/
|
|
2442
|
-
async deleteWorkspace(id, requestId) {
|
|
2443
|
-
z.string().parse(id);
|
|
2444
|
-
const response = await request({
|
|
2445
|
-
httpMethod: 'DELETE',
|
|
2446
|
-
baseUri: this.syncApiBase,
|
|
2447
|
-
relativePath: generatePath(ENDPOINT_REST_WORKSPACES, id),
|
|
2448
|
-
apiToken: this.authToken,
|
|
2449
|
-
customFetch: this.customFetch,
|
|
2450
|
-
requestId: requestId,
|
|
2451
|
-
});
|
|
2452
|
-
return isSuccess(response);
|
|
2453
|
-
}
|
|
2454
|
-
/**
|
|
2455
|
-
* Retrieves activity information for workspace members.
|
|
2456
|
-
*
|
|
2457
|
-
* @param args - Arguments including workspace ID and optional user/project filters.
|
|
2458
|
-
* @param requestId - Optional custom identifier for the request.
|
|
2459
|
-
* @returns A promise that resolves to workspace members activity data.
|
|
2460
|
-
*/
|
|
2461
|
-
async getWorkspaceMembersActivity(args, requestId) {
|
|
2462
|
-
const { workspaceId } = args, queryParams = __rest(args, ["workspaceId"]);
|
|
2463
|
-
const { data } = await request({
|
|
2464
|
-
httpMethod: 'GET',
|
|
2465
|
-
baseUri: this.syncApiBase,
|
|
2466
|
-
relativePath: ENDPOINT_WORKSPACE_MEMBERS,
|
|
2467
|
-
apiToken: this.authToken,
|
|
2468
|
-
customFetch: this.customFetch,
|
|
2469
|
-
payload: Object.assign({ workspaceId }, queryParams),
|
|
2470
|
-
requestId: requestId,
|
|
2471
|
-
});
|
|
2472
|
-
return {
|
|
2473
|
-
members: validateMemberActivityInfoArray(data.members),
|
|
2474
|
-
};
|
|
2475
|
-
}
|
|
2476
|
-
/**
|
|
2477
|
-
* Retrieves tasks assigned to a specific user in a workspace.
|
|
2478
|
-
*
|
|
2479
|
-
* @param args - Arguments including workspace ID, user ID, and optional project filter.
|
|
2480
|
-
* @param requestId - Optional custom identifier for the request.
|
|
2481
|
-
* @returns A promise that resolves to workspace user tasks.
|
|
2482
|
-
*/
|
|
2483
|
-
async getWorkspaceUserTasks(args, requestId) {
|
|
2484
|
-
const { workspaceId, userId } = args, queryParams = __rest(args, ["workspaceId", "userId"]);
|
|
2485
|
-
const { data } = await request({
|
|
2486
|
-
httpMethod: 'GET',
|
|
2487
|
-
baseUri: this.syncApiBase,
|
|
2488
|
-
relativePath: getWorkspaceUserTasksEndpoint(workspaceId, userId),
|
|
2489
|
-
apiToken: this.authToken,
|
|
2490
|
-
customFetch: this.customFetch,
|
|
2491
|
-
payload: queryParams,
|
|
2492
|
-
requestId: requestId,
|
|
2493
|
-
});
|
|
2494
|
-
return {
|
|
2495
|
-
tasks: validateWorkspaceUserTaskArray(data.tasks),
|
|
2496
|
-
};
|
|
2497
|
-
}
|
|
2498
|
-
/**
|
|
2499
|
-
* Invites users to a workspace by email.
|
|
2500
|
-
*
|
|
2501
|
-
* @param args - Arguments including workspace ID, email list, and optional role.
|
|
2502
|
-
* @param requestId - Optional custom identifier for the request.
|
|
2503
|
-
* @returns A promise that resolves to the list of invited emails.
|
|
2504
|
-
*/
|
|
2505
|
-
async inviteWorkspaceUsers(args, requestId) {
|
|
2506
|
-
const { workspaceId } = args, payload = __rest(args, ["workspaceId"]);
|
|
2507
|
-
const { data } = await request({
|
|
2508
|
-
httpMethod: 'POST',
|
|
2509
|
-
baseUri: this.syncApiBase,
|
|
2510
|
-
relativePath: getWorkspaceInviteUsersEndpoint(workspaceId),
|
|
2511
|
-
apiToken: this.authToken,
|
|
2512
|
-
customFetch: this.customFetch,
|
|
2513
|
-
payload: payload,
|
|
2514
|
-
requestId: requestId,
|
|
2515
|
-
});
|
|
2516
|
-
return data;
|
|
2517
|
-
}
|
|
2518
|
-
/**
|
|
2519
|
-
* Updates a workspace user's role.
|
|
2520
|
-
*
|
|
2521
|
-
* @param args - Arguments including workspace ID, user ID, and new role.
|
|
2522
|
-
* @param requestId - Optional custom identifier for the request.
|
|
2523
|
-
* @returns A promise that resolves to the updated workspace user view.
|
|
2524
|
-
*/
|
|
2525
|
-
async updateWorkspaceUser(args, requestId) {
|
|
2526
|
-
const { workspaceId, userId } = args, payload = __rest(args, ["workspaceId", "userId"]);
|
|
2527
|
-
const response = await request({
|
|
2528
|
-
httpMethod: 'POST',
|
|
2529
|
-
baseUri: this.syncApiBase,
|
|
2530
|
-
relativePath: getWorkspaceUserEndpoint(workspaceId, userId),
|
|
2531
|
-
apiToken: this.authToken,
|
|
2532
|
-
customFetch: this.customFetch,
|
|
2533
|
-
payload: payload,
|
|
2534
|
-
requestId: requestId,
|
|
2535
|
-
});
|
|
2536
|
-
return validateJoinWorkspaceResult(response.data);
|
|
2537
|
-
}
|
|
2538
|
-
/**
|
|
2539
|
-
* Removes a user from a workspace.
|
|
2540
|
-
*
|
|
2541
|
-
* @param args - Arguments including workspace ID and user ID.
|
|
2542
|
-
* @param requestId - Optional custom identifier for the request.
|
|
2543
|
-
* @returns A promise that resolves to `true` if successful.
|
|
2544
|
-
*/
|
|
2545
|
-
async removeWorkspaceUser(args, requestId) {
|
|
2546
|
-
const { workspaceId, userId } = args;
|
|
2547
|
-
const response = await request({
|
|
2548
|
-
httpMethod: 'DELETE',
|
|
2549
|
-
baseUri: this.syncApiBase,
|
|
2550
|
-
relativePath: getWorkspaceUserEndpoint(workspaceId, userId),
|
|
2551
|
-
apiToken: this.authToken,
|
|
2552
|
-
customFetch: this.customFetch,
|
|
2553
|
-
requestId: requestId,
|
|
2554
|
-
});
|
|
2555
|
-
return isSuccess(response);
|
|
2556
|
-
}
|
|
2557
|
-
/**
|
|
2558
|
-
* Gets active projects in a workspace with pagination.
|
|
2559
|
-
*
|
|
2560
|
-
* @param args - Arguments including workspace ID, cursor, and limit.
|
|
2561
|
-
* @param requestId - Optional request ID for idempotency.
|
|
2562
|
-
* @returns Paginated list of active workspace projects.
|
|
2563
|
-
*/
|
|
2564
|
-
async getWorkspaceActiveProjects(args, requestId) {
|
|
2565
|
-
var _a;
|
|
2566
|
-
const queryParams = {};
|
|
2567
|
-
if (args.cursor) {
|
|
2568
|
-
queryParams.cursor = args.cursor;
|
|
2569
|
-
}
|
|
2570
|
-
if (args.limit) {
|
|
2571
|
-
queryParams.limit = args.limit;
|
|
2572
|
-
}
|
|
2573
|
-
const response = await request({
|
|
2574
|
-
httpMethod: 'GET',
|
|
2575
|
-
baseUri: this.syncApiBase,
|
|
2576
|
-
relativePath: getWorkspaceActiveProjectsEndpoint(args.workspaceId),
|
|
2577
|
-
apiToken: this.authToken,
|
|
2578
|
-
customFetch: this.customFetch,
|
|
2579
|
-
payload: queryParams,
|
|
2580
|
-
requestId: requestId,
|
|
2581
|
-
});
|
|
2582
|
-
// oxlint-disable-next-line no-unsafe-assignment, no-unsafe-call, no-unsafe-member-access
|
|
2583
|
-
const validatedProjects = (_a = response.data.results) === null || _a === void 0 ? void 0 : _a.map((project) => validateProject(project));
|
|
2584
|
-
return Object.assign(Object.assign({}, response.data), {
|
|
2585
|
-
// oxlint-disable-next-line no-unsafe-assignment
|
|
2586
|
-
results: validatedProjects || [] });
|
|
2587
|
-
}
|
|
2588
|
-
/**
|
|
2589
|
-
* Gets archived projects in a workspace with pagination.
|
|
2590
|
-
*
|
|
2591
|
-
* @param args - Arguments including workspace ID, cursor, and limit.
|
|
2592
|
-
* @param requestId - Optional request ID for idempotency.
|
|
2593
|
-
* @returns Paginated list of archived workspace projects.
|
|
2594
|
-
*/
|
|
2595
|
-
async getWorkspaceArchivedProjects(args, requestId) {
|
|
2596
|
-
var _a;
|
|
2597
|
-
const queryParams = {};
|
|
2598
|
-
if (args.cursor) {
|
|
2599
|
-
queryParams.cursor = args.cursor;
|
|
2600
|
-
}
|
|
2601
|
-
if (args.limit) {
|
|
2602
|
-
queryParams.limit = args.limit;
|
|
2603
|
-
}
|
|
2604
|
-
const response = await request({
|
|
2605
|
-
httpMethod: 'GET',
|
|
2606
|
-
baseUri: this.syncApiBase,
|
|
2607
|
-
relativePath: getWorkspaceArchivedProjectsEndpoint(args.workspaceId),
|
|
2608
|
-
apiToken: this.authToken,
|
|
2609
|
-
customFetch: this.customFetch,
|
|
2610
|
-
payload: queryParams,
|
|
2611
|
-
requestId: requestId,
|
|
2612
|
-
});
|
|
2613
|
-
// oxlint-disable-next-line no-unsafe-assignment, no-unsafe-call, no-unsafe-member-access
|
|
2614
|
-
const validatedProjects = (_a = response.data.results) === null || _a === void 0 ? void 0 : _a.map((project) => validateProject(project));
|
|
2615
|
-
return Object.assign(Object.assign({}, response.data), {
|
|
2616
|
-
// oxlint-disable-next-line no-unsafe-assignment
|
|
2617
|
-
results: validatedProjects || [] });
|
|
2618
|
-
}
|
|
2619
|
-
}
|