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