@doist/todoist-api-typescript 7.9.1 → 7.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -204
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.mjs +1 -0
- package/package.json +12 -92
- package/LICENSE +0 -21
- package/dist/cjs/authentication.js +0 -204
- package/dist/cjs/consts/endpoints.js +0 -141
- package/dist/cjs/index.js +0 -20
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/test-utils/asserts.js +0 -11
- package/dist/cjs/test-utils/msw-setup.js +0 -97
- package/dist/cjs/test-utils/obsidian-fetch-adapter.js +0 -53
- package/dist/cjs/test-utils/test-defaults.js +0 -240
- package/dist/cjs/todoist-api.js +0 -2623
- package/dist/cjs/transport/fetch-with-retry.js +0 -206
- package/dist/cjs/transport/http-client.js +0 -133
- package/dist/cjs/transport/http-dispatcher.js +0 -72
- package/dist/cjs/types/activity/index.js +0 -18
- package/dist/cjs/types/activity/requests.js +0 -2
- package/dist/cjs/types/activity/types.js +0 -28
- package/dist/cjs/types/backups/index.js +0 -18
- package/dist/cjs/types/backups/requests.js +0 -2
- package/dist/cjs/types/backups/types.js +0 -8
- package/dist/cjs/types/comments/index.js +0 -18
- package/dist/cjs/types/comments/requests.js +0 -2
- package/dist/cjs/types/comments/types.js +0 -60
- package/dist/cjs/types/common.js +0 -10
- package/dist/cjs/types/emails/index.js +0 -17
- package/dist/cjs/types/emails/requests.js +0 -5
- package/dist/cjs/types/errors.js +0 -29
- package/dist/cjs/types/folders/index.js +0 -17
- package/dist/cjs/types/folders/requests.js +0 -2
- package/dist/cjs/types/http.js +0 -24
- package/dist/cjs/types/id-mappings/index.js +0 -18
- package/dist/cjs/types/id-mappings/requests.js +0 -20
- package/dist/cjs/types/id-mappings/types.js +0 -12
- package/dist/cjs/types/index.js +0 -36
- package/dist/cjs/types/insights/index.js +0 -18
- package/dist/cjs/types/insights/requests.js +0 -2
- package/dist/cjs/types/insights/types.js +0 -84
- package/dist/cjs/types/labels/index.js +0 -18
- package/dist/cjs/types/labels/requests.js +0 -2
- package/dist/cjs/types/labels/types.js +0 -11
- package/dist/cjs/types/productivity/index.js +0 -17
- package/dist/cjs/types/productivity/types.js +0 -67
- package/dist/cjs/types/projects/index.js +0 -18
- package/dist/cjs/types/projects/requests.js +0 -2
- package/dist/cjs/types/projects/types.js +0 -56
- package/dist/cjs/types/reminders/index.js +0 -17
- package/dist/cjs/types/reminders/requests.js +0 -95
- package/dist/cjs/types/sections/index.js +0 -18
- package/dist/cjs/types/sections/requests.js +0 -2
- package/dist/cjs/types/sections/types.js +0 -22
- package/dist/cjs/types/sync/commands/calendars.js +0 -2
- package/dist/cjs/types/sync/commands/filters.js +0 -2
- package/dist/cjs/types/sync/commands/folders.js +0 -2
- package/dist/cjs/types/sync/commands/index.js +0 -35
- package/dist/cjs/types/sync/commands/labels.js +0 -5
- package/dist/cjs/types/sync/commands/notes.js +0 -2
- package/dist/cjs/types/sync/commands/notifications.js +0 -2
- package/dist/cjs/types/sync/commands/others.js +0 -2
- package/dist/cjs/types/sync/commands/project-view-options.js +0 -2
- package/dist/cjs/types/sync/commands/projects.js +0 -2
- package/dist/cjs/types/sync/commands/reminders.js +0 -2
- package/dist/cjs/types/sync/commands/sections.js +0 -2
- package/dist/cjs/types/sync/commands/shared.js +0 -20
- package/dist/cjs/types/sync/commands/sharing.js +0 -2
- package/dist/cjs/types/sync/commands/tasks.js +0 -2
- package/dist/cjs/types/sync/commands/view-options.js +0 -2
- package/dist/cjs/types/sync/commands/workspace-filters.js +0 -2
- package/dist/cjs/types/sync/commands/workspace-goals.js +0 -2
- package/dist/cjs/types/sync/commands/workspaces.js +0 -2
- package/dist/cjs/types/sync/index.js +0 -22
- package/dist/cjs/types/sync/request.js +0 -2
- package/dist/cjs/types/sync/resource-types.js +0 -40
- package/dist/cjs/types/sync/resources/calendars.js +0 -31
- package/dist/cjs/types/sync/resources/collaborators.js +0 -25
- package/dist/cjs/types/sync/resources/completed-info.js +0 -30
- package/dist/cjs/types/sync/resources/filters.js +0 -16
- package/dist/cjs/types/sync/resources/folders.js +0 -14
- package/dist/cjs/types/sync/resources/index.js +0 -33
- package/dist/cjs/types/sync/resources/live-notifications.js +0 -39
- package/dist/cjs/types/sync/resources/notes.js +0 -23
- package/dist/cjs/types/sync/resources/reminders.js +0 -50
- package/dist/cjs/types/sync/resources/suggestions.js +0 -42
- package/dist/cjs/types/sync/resources/tooltips.js +0 -10
- package/dist/cjs/types/sync/resources/user-plan-limits.js +0 -24
- package/dist/cjs/types/sync/resources/user-settings.js +0 -42
- package/dist/cjs/types/sync/resources/user.js +0 -120
- package/dist/cjs/types/sync/resources/view-options.js +0 -83
- package/dist/cjs/types/sync/resources/workspace-filters.js +0 -21
- package/dist/cjs/types/sync/resources/workspace-goals.js +0 -32
- package/dist/cjs/types/sync/resources/workspaces.js +0 -73
- package/dist/cjs/types/sync/response.js +0 -2
- package/dist/cjs/types/sync/user-preferences.js +0 -71
- package/dist/cjs/types/tasks/index.js +0 -18
- package/dist/cjs/types/tasks/requests.js +0 -2
- package/dist/cjs/types/tasks/types.js +0 -59
- package/dist/cjs/types/templates/index.js +0 -17
- package/dist/cjs/types/templates/requests.js +0 -2
- package/dist/cjs/types/uploads/index.js +0 -17
- package/dist/cjs/types/uploads/requests.js +0 -2
- package/dist/cjs/types/users/index.js +0 -17
- package/dist/cjs/types/users/types.js +0 -51
- package/dist/cjs/types/workspaces/index.js +0 -18
- package/dist/cjs/types/workspaces/requests.js +0 -2
- package/dist/cjs/types/workspaces/types.js +0 -155
- package/dist/cjs/utils/activity-helpers.js +0 -58
- package/dist/cjs/utils/case-conversion.js +0 -69
- package/dist/cjs/utils/colors.js +0 -143
- package/dist/cjs/utils/index.js +0 -25
- package/dist/cjs/utils/multipart-upload.js +0 -178
- package/dist/cjs/utils/processing-helpers.js +0 -18
- package/dist/cjs/utils/sanitization.js +0 -116
- package/dist/cjs/utils/sync-helpers.js +0 -22
- package/dist/cjs/utils/uncompletable-helpers.js +0 -60
- package/dist/cjs/utils/url-helpers.js +0 -74
- package/dist/cjs/utils/validators.js +0 -141
- package/dist/esm/authentication.js +0 -196
- package/dist/esm/consts/endpoints.js +0 -122
- package/dist/esm/index.js +0 -4
- package/dist/esm/test-utils/asserts.js +0 -8
- package/dist/esm/test-utils/msw-setup.js +0 -88
- package/dist/esm/test-utils/obsidian-fetch-adapter.js +0 -50
- package/dist/esm/test-utils/test-defaults.js +0 -237
- package/dist/esm/todoist-api.js +0 -2619
- package/dist/esm/transport/fetch-with-retry.js +0 -203
- package/dist/esm/transport/http-client.js +0 -128
- package/dist/esm/transport/http-dispatcher.js +0 -35
- package/dist/esm/types/activity/index.js +0 -2
- package/dist/esm/types/activity/requests.js +0 -1
- package/dist/esm/types/activity/types.js +0 -25
- package/dist/esm/types/backups/index.js +0 -2
- package/dist/esm/types/backups/requests.js +0 -1
- package/dist/esm/types/backups/types.js +0 -5
- package/dist/esm/types/comments/index.js +0 -2
- package/dist/esm/types/comments/requests.js +0 -1
- package/dist/esm/types/comments/types.js +0 -57
- package/dist/esm/types/common.js +0 -7
- package/dist/esm/types/emails/index.js +0 -1
- package/dist/esm/types/emails/requests.js +0 -2
- package/dist/esm/types/errors.js +0 -24
- package/dist/esm/types/folders/index.js +0 -1
- package/dist/esm/types/folders/requests.js +0 -1
- package/dist/esm/types/http.js +0 -20
- package/dist/esm/types/id-mappings/index.js +0 -2
- package/dist/esm/types/id-mappings/requests.js +0 -17
- package/dist/esm/types/id-mappings/types.js +0 -9
- package/dist/esm/types/index.js +0 -20
- package/dist/esm/types/insights/index.js +0 -2
- package/dist/esm/types/insights/requests.js +0 -1
- package/dist/esm/types/insights/types.js +0 -81
- package/dist/esm/types/labels/index.js +0 -2
- package/dist/esm/types/labels/requests.js +0 -1
- package/dist/esm/types/labels/types.js +0 -8
- package/dist/esm/types/productivity/index.js +0 -1
- package/dist/esm/types/productivity/types.js +0 -64
- package/dist/esm/types/projects/index.js +0 -2
- package/dist/esm/types/projects/requests.js +0 -1
- package/dist/esm/types/projects/types.js +0 -53
- package/dist/esm/types/reminders/index.js +0 -1
- package/dist/esm/types/reminders/requests.js +0 -92
- package/dist/esm/types/sections/index.js +0 -2
- package/dist/esm/types/sections/requests.js +0 -1
- package/dist/esm/types/sections/types.js +0 -19
- package/dist/esm/types/sync/commands/calendars.js +0 -1
- package/dist/esm/types/sync/commands/filters.js +0 -1
- package/dist/esm/types/sync/commands/folders.js +0 -1
- package/dist/esm/types/sync/commands/index.js +0 -19
- package/dist/esm/types/sync/commands/labels.js +0 -2
- package/dist/esm/types/sync/commands/notes.js +0 -1
- package/dist/esm/types/sync/commands/notifications.js +0 -1
- package/dist/esm/types/sync/commands/others.js +0 -1
- package/dist/esm/types/sync/commands/project-view-options.js +0 -1
- package/dist/esm/types/sync/commands/projects.js +0 -1
- package/dist/esm/types/sync/commands/reminders.js +0 -1
- package/dist/esm/types/sync/commands/sections.js +0 -1
- package/dist/esm/types/sync/commands/shared.js +0 -16
- package/dist/esm/types/sync/commands/sharing.js +0 -1
- package/dist/esm/types/sync/commands/tasks.js +0 -1
- package/dist/esm/types/sync/commands/view-options.js +0 -1
- package/dist/esm/types/sync/commands/workspace-filters.js +0 -1
- package/dist/esm/types/sync/commands/workspace-goals.js +0 -1
- package/dist/esm/types/sync/commands/workspaces.js +0 -1
- package/dist/esm/types/sync/index.js +0 -6
- package/dist/esm/types/sync/request.js +0 -1
- package/dist/esm/types/sync/resource-types.js +0 -37
- package/dist/esm/types/sync/resources/calendars.js +0 -28
- package/dist/esm/types/sync/resources/collaborators.js +0 -22
- package/dist/esm/types/sync/resources/completed-info.js +0 -27
- package/dist/esm/types/sync/resources/filters.js +0 -13
- package/dist/esm/types/sync/resources/folders.js +0 -11
- package/dist/esm/types/sync/resources/index.js +0 -17
- package/dist/esm/types/sync/resources/live-notifications.js +0 -36
- package/dist/esm/types/sync/resources/notes.js +0 -20
- package/dist/esm/types/sync/resources/reminders.js +0 -47
- package/dist/esm/types/sync/resources/suggestions.js +0 -39
- package/dist/esm/types/sync/resources/tooltips.js +0 -7
- package/dist/esm/types/sync/resources/user-plan-limits.js +0 -21
- package/dist/esm/types/sync/resources/user-settings.js +0 -39
- package/dist/esm/types/sync/resources/user.js +0 -117
- package/dist/esm/types/sync/resources/view-options.js +0 -80
- package/dist/esm/types/sync/resources/workspace-filters.js +0 -18
- package/dist/esm/types/sync/resources/workspace-goals.js +0 -29
- package/dist/esm/types/sync/resources/workspaces.js +0 -70
- package/dist/esm/types/sync/response.js +0 -1
- package/dist/esm/types/sync/user-preferences.js +0 -68
- package/dist/esm/types/tasks/index.js +0 -2
- package/dist/esm/types/tasks/requests.js +0 -1
- package/dist/esm/types/tasks/types.js +0 -56
- package/dist/esm/types/templates/index.js +0 -1
- package/dist/esm/types/templates/requests.js +0 -1
- package/dist/esm/types/uploads/index.js +0 -1
- package/dist/esm/types/uploads/requests.js +0 -1
- package/dist/esm/types/users/index.js +0 -1
- package/dist/esm/types/users/types.js +0 -48
- package/dist/esm/types/workspaces/index.js +0 -2
- package/dist/esm/types/workspaces/requests.js +0 -1
- package/dist/esm/types/workspaces/types.js +0 -152
- package/dist/esm/utils/activity-helpers.js +0 -53
- package/dist/esm/utils/case-conversion.js +0 -61
- package/dist/esm/utils/colors.js +0 -139
- package/dist/esm/utils/index.js +0 -4
- package/dist/esm/utils/multipart-upload.js +0 -142
- package/dist/esm/utils/processing-helpers.js +0 -12
- package/dist/esm/utils/sanitization.js +0 -112
- package/dist/esm/utils/sync-helpers.js +0 -19
- package/dist/esm/utils/uncompletable-helpers.js +0 -54
- package/dist/esm/utils/url-helpers.js +0 -68
- package/dist/esm/utils/validators.js +0 -132
- package/dist/types/authentication.d.ts +0 -158
- package/dist/types/consts/endpoints.d.ts +0 -81
- package/dist/types/index.d.ts +0 -4
- package/dist/types/test-utils/asserts.d.ts +0 -1
- package/dist/types/test-utils/msw-setup.d.ts +0 -33
- package/dist/types/test-utils/obsidian-fetch-adapter.d.ts +0 -29
- package/dist/types/test-utils/test-defaults.d.ts +0 -261
- package/dist/types/todoist-api.d.ts +0 -1018
- package/dist/types/transport/fetch-with-retry.d.ts +0 -12
- package/dist/types/transport/http-client.d.ts +0 -16
- package/dist/types/transport/http-dispatcher.d.ts +0 -3
- package/dist/types/types/activity/index.d.ts +0 -2
- package/dist/types/types/activity/requests.d.ts +0 -85
- package/dist/types/types/activity/types.d.ts +0 -49
- package/dist/types/types/backups/index.d.ts +0 -2
- package/dist/types/types/backups/requests.d.ts +0 -16
- package/dist/types/types/backups/types.d.ts +0 -7
- package/dist/types/types/comments/index.d.ts +0 -2
- package/dist/types/types/comments/requests.d.ts +0 -64
- package/dist/types/types/comments/types.d.ts +0 -141
- package/dist/types/types/common.d.ts +0 -13
- package/dist/types/types/emails/index.d.ts +0 -1
- package/dist/types/types/emails/requests.d.ts +0 -30
- package/dist/types/types/errors.d.ts +0 -12
- package/dist/types/types/folders/index.d.ts +0 -1
- package/dist/types/types/folders/requests.d.ts +0 -20
- package/dist/types/types/http.d.ts +0 -85
- package/dist/types/types/id-mappings/index.d.ts +0 -2
- package/dist/types/types/id-mappings/requests.d.ts +0 -28
- package/dist/types/types/id-mappings/types.d.ts +0 -13
- package/dist/types/types/index.d.ts +0 -20
- package/dist/types/types/insights/index.d.ts +0 -2
- package/dist/types/types/insights/requests.d.ts +0 -26
- package/dist/types/types/insights/types.d.ts +0 -186
- package/dist/types/types/labels/index.d.ts +0 -2
- package/dist/types/types/labels/requests.d.ts +0 -75
- package/dist/types/types/labels/types.d.ts +0 -13
- package/dist/types/types/productivity/index.d.ts +0 -1
- package/dist/types/types/productivity/types.d.ts +0 -115
- package/dist/types/types/projects/index.d.ts +0 -2
- package/dist/types/types/projects/requests.d.ts +0 -169
- package/dist/types/types/projects/types.d.ts +0 -201
- package/dist/types/types/reminders/index.d.ts +0 -1
- package/dist/types/types/reminders/requests.d.ts +0 -205
- package/dist/types/types/sections/index.d.ts +0 -2
- package/dist/types/types/sections/requests.d.ts +0 -41
- package/dist/types/types/sections/types.d.ts +0 -44
- package/dist/types/types/sync/commands/calendars.d.ts +0 -14
- package/dist/types/types/sync/commands/filters.d.ts +0 -22
- package/dist/types/types/sync/commands/folders.d.ts +0 -18
- package/dist/types/types/sync/commands/index.d.ts +0 -171
- package/dist/types/types/sync/commands/labels.d.ts +0 -32
- package/dist/types/types/sync/commands/notes.d.ts +0 -27
- package/dist/types/types/sync/commands/notifications.d.ts +0 -10
- package/dist/types/types/sync/commands/others.d.ts +0 -39
- package/dist/types/types/sync/commands/project-view-options.d.ts +0 -14
- package/dist/types/types/sync/commands/projects.d.ts +0 -90
- package/dist/types/types/sync/commands/reminders.d.ts +0 -51
- package/dist/types/types/sync/commands/sections.d.ts +0 -31
- package/dist/types/types/sync/commands/shared.d.ts +0 -51
- package/dist/types/types/sync/commands/sharing.d.ts +0 -16
- package/dist/types/types/sync/commands/tasks.d.ts +0 -78
- package/dist/types/types/sync/commands/view-options.d.ts +0 -15
- package/dist/types/types/sync/commands/workspace-filters.d.ts +0 -23
- package/dist/types/types/sync/commands/workspace-goals.d.ts +0 -24
- package/dist/types/types/sync/commands/workspaces.d.ts +0 -79
- package/dist/types/types/sync/index.d.ts +0 -6
- package/dist/types/types/sync/request.d.ts +0 -7
- package/dist/types/types/sync/resource-types.d.ts +0 -5
- package/dist/types/types/sync/resources/calendars.d.ts +0 -38
- package/dist/types/types/sync/resources/collaborators.d.ts +0 -28
- package/dist/types/types/sync/resources/completed-info.d.ts +0 -33
- package/dist/types/types/sync/resources/filters.d.ts +0 -12
- package/dist/types/types/sync/resources/folders.d.ts +0 -10
- package/dist/types/types/sync/resources/index.d.ts +0 -17
- package/dist/types/types/sync/resources/live-notifications.d.ts +0 -32
- package/dist/types/types/sync/resources/notes.d.ts +0 -34
- package/dist/types/types/sync/resources/reminders.d.ts +0 -126
- package/dist/types/types/sync/resources/suggestions.d.ts +0 -96
- package/dist/types/types/sync/resources/tooltips.d.ts +0 -6
- package/dist/types/types/sync/resources/user-plan-limits.d.ts +0 -41
- package/dist/types/types/sync/resources/user-settings.d.ts +0 -40
- package/dist/types/types/sync/resources/user.d.ts +0 -134
- package/dist/types/types/sync/resources/view-options.d.ts +0 -169
- package/dist/types/types/sync/resources/workspace-filters.d.ts +0 -17
- package/dist/types/types/sync/resources/workspace-goals.d.ts +0 -29
- package/dist/types/types/sync/resources/workspaces.d.ts +0 -142
- package/dist/types/types/sync/response.d.ts +0 -51
- package/dist/types/types/sync/user-preferences.d.ts +0 -39
- package/dist/types/types/tasks/index.d.ts +0 -2
- package/dist/types/types/tasks/requests.d.ts +0 -197
- package/dist/types/types/tasks/types.d.ts +0 -162
- package/dist/types/types/templates/index.d.ts +0 -1
- package/dist/types/types/templates/requests.d.ts +0 -92
- package/dist/types/types/uploads/index.d.ts +0 -1
- package/dist/types/types/uploads/requests.d.ts +0 -32
- package/dist/types/types/users/index.d.ts +0 -1
- package/dist/types/types/users/types.d.ts +0 -66
- package/dist/types/types/workspaces/index.d.ts +0 -2
- package/dist/types/types/workspaces/requests.d.ts +0 -260
- package/dist/types/types/workspaces/types.d.ts +0 -267
- package/dist/types/utils/activity-helpers.d.ts +0 -28
- package/dist/types/utils/case-conversion.d.ts +0 -12
- package/dist/types/utils/colors.d.ts +0 -197
- package/dist/types/utils/index.d.ts +0 -4
- package/dist/types/utils/multipart-upload.d.ts +0 -54
- package/dist/types/utils/processing-helpers.d.ts +0 -1
- package/dist/types/utils/sanitization.d.ts +0 -35
- package/dist/types/utils/sync-helpers.d.ts +0 -17
- package/dist/types/utils/uncompletable-helpers.d.ts +0 -30
- package/dist/types/utils/url-helpers.d.ts +0 -32
- package/dist/types/utils/validators.d.ts +0 -1404
|
@@ -1,206 +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.fetchWithRetry = fetchWithRetry;
|
|
15
|
-
const http_1 = require("../types/http");
|
|
16
|
-
const http_dispatcher_1 = require("./http-dispatcher");
|
|
17
|
-
/**
|
|
18
|
-
* Default retry configuration matching the original axios-retry behavior
|
|
19
|
-
*/
|
|
20
|
-
const DEFAULT_RETRY_CONFIG = {
|
|
21
|
-
retries: 3,
|
|
22
|
-
retryCondition: http_1.isNetworkError,
|
|
23
|
-
retryDelay: (retryNumber) => {
|
|
24
|
-
// First retry: immediate (0ms delay)
|
|
25
|
-
// Subsequent retries: 500ms delay
|
|
26
|
-
return retryNumber === 1 ? 0 : 500;
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
const TIMEOUT_ERROR_NAME = 'TimeoutError';
|
|
30
|
-
function createTimeoutError(timeoutMs) {
|
|
31
|
-
const error = new Error(`Request timeout after ${timeoutMs}ms`);
|
|
32
|
-
error.name = TIMEOUT_ERROR_NAME;
|
|
33
|
-
return error;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Converts Headers object to a plain object
|
|
37
|
-
*/
|
|
38
|
-
function headersToObject(headers) {
|
|
39
|
-
const result = {};
|
|
40
|
-
headers.forEach((value, key) => {
|
|
41
|
-
result[key] = value;
|
|
42
|
-
});
|
|
43
|
-
return result;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Creates an AbortSignal that aborts after timeoutMs. Returns the signal and a
|
|
47
|
-
* clear function to cancel the timeout early.
|
|
48
|
-
*/
|
|
49
|
-
function createTimeoutSignal(timeoutMs, existingSignal) {
|
|
50
|
-
const controller = new AbortController();
|
|
51
|
-
// Timeout logic
|
|
52
|
-
const timeoutId = setTimeout(() => {
|
|
53
|
-
controller.abort(createTimeoutError(timeoutMs));
|
|
54
|
-
}, timeoutMs);
|
|
55
|
-
let abortHandler;
|
|
56
|
-
function clear() {
|
|
57
|
-
clearTimeout(timeoutId);
|
|
58
|
-
if (existingSignal && abortHandler) {
|
|
59
|
-
existingSignal.removeEventListener('abort', abortHandler);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
// If there's an existing signal, forward its abort
|
|
63
|
-
if (existingSignal) {
|
|
64
|
-
if (existingSignal.aborted) {
|
|
65
|
-
clearTimeout(timeoutId);
|
|
66
|
-
controller.abort(existingSignal.reason);
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
abortHandler = () => {
|
|
70
|
-
clearTimeout(timeoutId);
|
|
71
|
-
controller.abort(existingSignal.reason);
|
|
72
|
-
};
|
|
73
|
-
existingSignal.addEventListener('abort', abortHandler, { once: true });
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
// Clean up timeout when request completes
|
|
77
|
-
controller.signal.addEventListener('abort', () => {
|
|
78
|
-
clearTimeout(timeoutId);
|
|
79
|
-
});
|
|
80
|
-
return { signal: controller.signal, clear };
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Converts native fetch Response to CustomFetchResponse for consistency
|
|
84
|
-
*/
|
|
85
|
-
function convertResponseToCustomFetch(response) {
|
|
86
|
-
// Clone the response so we can read it multiple times (if clone method exists)
|
|
87
|
-
const clonedResponse = response.clone ? response.clone() : response;
|
|
88
|
-
return {
|
|
89
|
-
ok: response.ok,
|
|
90
|
-
status: response.status,
|
|
91
|
-
statusText: response.statusText,
|
|
92
|
-
headers: headersToObject(response.headers),
|
|
93
|
-
text: () => clonedResponse.text(),
|
|
94
|
-
json: () => response.json(),
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Performs a fetch request with retry logic and timeout support
|
|
99
|
-
*/
|
|
100
|
-
async function fetchWithRetry(args) {
|
|
101
|
-
const { url, options = {}, retryConfig = {}, customFetch } = args;
|
|
102
|
-
const config = Object.assign(Object.assign({}, DEFAULT_RETRY_CONFIG), retryConfig);
|
|
103
|
-
const { timeout, signal: userSignal } = options, fetchOptions = __rest(options, ["timeout", "signal"]);
|
|
104
|
-
let lastError;
|
|
105
|
-
for (let attempt = 0; attempt <= config.retries; attempt++) {
|
|
106
|
-
// Timeout clear function for this attempt (hoisted for catch scope)
|
|
107
|
-
let clearTimeoutFn;
|
|
108
|
-
try {
|
|
109
|
-
// Set up timeout and signal handling
|
|
110
|
-
let requestSignal = userSignal || undefined;
|
|
111
|
-
if (timeout && timeout > 0) {
|
|
112
|
-
const timeoutResult = createTimeoutSignal(timeout, requestSignal);
|
|
113
|
-
requestSignal = timeoutResult.signal;
|
|
114
|
-
clearTimeoutFn = timeoutResult.clear;
|
|
115
|
-
}
|
|
116
|
-
// Use custom fetch or native fetch
|
|
117
|
-
let fetchResponse;
|
|
118
|
-
if (customFetch) {
|
|
119
|
-
fetchResponse = await customFetch(url, Object.assign(Object.assign({}, fetchOptions), { signal: requestSignal, timeout }));
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
const dispatcher = await (0, http_dispatcher_1.getDefaultDispatcher)();
|
|
123
|
-
const nativeFetchOptions = Object.assign(Object.assign({}, fetchOptions), { signal: requestSignal });
|
|
124
|
-
if (dispatcher !== undefined) {
|
|
125
|
-
// @ts-expect-error - dispatcher is a valid option for Node.js fetch but not in the TS types
|
|
126
|
-
nativeFetchOptions.dispatcher = dispatcher;
|
|
127
|
-
}
|
|
128
|
-
const nativeResponse = await fetch(url, nativeFetchOptions);
|
|
129
|
-
fetchResponse = convertResponseToCustomFetch(nativeResponse);
|
|
130
|
-
}
|
|
131
|
-
// Check if the response is successful
|
|
132
|
-
if (!fetchResponse.ok) {
|
|
133
|
-
const errorMessage = `HTTP ${fetchResponse.status}: ${fetchResponse.statusText}`;
|
|
134
|
-
const error = new Error(errorMessage);
|
|
135
|
-
error.status = fetchResponse.status;
|
|
136
|
-
error.statusText = fetchResponse.statusText;
|
|
137
|
-
error.response = {
|
|
138
|
-
data: undefined, // Will be set below if we can parse the response
|
|
139
|
-
status: fetchResponse.status,
|
|
140
|
-
statusText: fetchResponse.statusText,
|
|
141
|
-
headers: fetchResponse.headers,
|
|
142
|
-
};
|
|
143
|
-
// Try to get response body for error details
|
|
144
|
-
try {
|
|
145
|
-
const responseText = await fetchResponse.text();
|
|
146
|
-
let responseData;
|
|
147
|
-
try {
|
|
148
|
-
responseData = responseText ? JSON.parse(responseText) : undefined;
|
|
149
|
-
}
|
|
150
|
-
catch (_a) {
|
|
151
|
-
responseData = responseText;
|
|
152
|
-
}
|
|
153
|
-
error.data = responseData;
|
|
154
|
-
error.response.data = responseData;
|
|
155
|
-
}
|
|
156
|
-
catch (_b) {
|
|
157
|
-
// If we can't read the response body, that's OK
|
|
158
|
-
}
|
|
159
|
-
throw error;
|
|
160
|
-
}
|
|
161
|
-
// Parse response
|
|
162
|
-
const responseText = await fetchResponse.text();
|
|
163
|
-
let data;
|
|
164
|
-
try {
|
|
165
|
-
data = responseText ? JSON.parse(responseText) : undefined;
|
|
166
|
-
}
|
|
167
|
-
catch (_c) {
|
|
168
|
-
// If JSON parsing fails, return the raw text
|
|
169
|
-
data = responseText;
|
|
170
|
-
}
|
|
171
|
-
// Success – clear pending timeout (if any) so Node can exit promptly
|
|
172
|
-
if (clearTimeoutFn) {
|
|
173
|
-
clearTimeoutFn();
|
|
174
|
-
}
|
|
175
|
-
return {
|
|
176
|
-
data,
|
|
177
|
-
status: fetchResponse.status,
|
|
178
|
-
statusText: fetchResponse.statusText,
|
|
179
|
-
headers: fetchResponse.headers,
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
catch (error) {
|
|
183
|
-
if (clearTimeoutFn) {
|
|
184
|
-
clearTimeoutFn();
|
|
185
|
-
}
|
|
186
|
-
lastError = error;
|
|
187
|
-
// Check if this error should trigger a retry
|
|
188
|
-
const shouldRetry = attempt < config.retries && config.retryCondition(lastError);
|
|
189
|
-
if (!shouldRetry) {
|
|
190
|
-
// Add network error flag for network errors
|
|
191
|
-
if ((0, http_1.isNetworkError)(lastError)) {
|
|
192
|
-
const networkError = lastError;
|
|
193
|
-
networkError.isNetworkError = true;
|
|
194
|
-
}
|
|
195
|
-
throw lastError;
|
|
196
|
-
}
|
|
197
|
-
// Wait before retrying
|
|
198
|
-
const delay = config.retryDelay(attempt + 1);
|
|
199
|
-
if (delay > 0) {
|
|
200
|
-
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
// This should never be reached, but just in case
|
|
205
|
-
throw lastError || new Error('Request failed after retries');
|
|
206
|
-
}
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.paramsSerializer = paramsSerializer;
|
|
4
|
-
exports.isSuccess = isSuccess;
|
|
5
|
-
exports.request = request;
|
|
6
|
-
const uuid_1 = require("uuid");
|
|
7
|
-
const endpoints_1 = require("../consts/endpoints");
|
|
8
|
-
const errors_1 = require("../types/errors");
|
|
9
|
-
const http_1 = require("../types/http");
|
|
10
|
-
const case_conversion_1 = require("../utils/case-conversion");
|
|
11
|
-
const fetch_with_retry_1 = require("./fetch-with-retry");
|
|
12
|
-
function paramsSerializer(params) {
|
|
13
|
-
const qs = new URLSearchParams();
|
|
14
|
-
Object.keys(params).forEach((key) => {
|
|
15
|
-
const value = params[key];
|
|
16
|
-
if (value !== null && value !== undefined) {
|
|
17
|
-
if (Array.isArray(value)) {
|
|
18
|
-
qs.append(key, JSON.stringify(value));
|
|
19
|
-
}
|
|
20
|
-
else if (typeof value === 'string' ||
|
|
21
|
-
typeof value === 'number' ||
|
|
22
|
-
typeof value === 'boolean') {
|
|
23
|
-
qs.append(key, String(value));
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
qs.append(key, JSON.stringify(value));
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
return qs.toString();
|
|
31
|
-
}
|
|
32
|
-
const defaultHeaders = {
|
|
33
|
-
'Content-Type': 'application/json',
|
|
34
|
-
};
|
|
35
|
-
function getAuthHeader(apiKey) {
|
|
36
|
-
return `Bearer ${apiKey}`;
|
|
37
|
-
}
|
|
38
|
-
function getRetryDelay(retryCount) {
|
|
39
|
-
return retryCount === 1 ? 0 : 500;
|
|
40
|
-
}
|
|
41
|
-
function getTodoistRequestError(args) {
|
|
42
|
-
const { error, originalStack } = args;
|
|
43
|
-
const requestError = new errors_1.TodoistRequestError(error.message);
|
|
44
|
-
requestError.stack = originalStack ? originalStack.stack : error.stack;
|
|
45
|
-
if ((0, http_1.isHttpError)(error)) {
|
|
46
|
-
requestError.httpStatusCode = error.status;
|
|
47
|
-
requestError.responseData = error.data;
|
|
48
|
-
}
|
|
49
|
-
return requestError;
|
|
50
|
-
}
|
|
51
|
-
function getRequestConfiguration(args) {
|
|
52
|
-
const { baseURL, apiToken, requestId, customHeaders } = args;
|
|
53
|
-
const authHeader = apiToken ? { Authorization: getAuthHeader(apiToken) } : undefined;
|
|
54
|
-
const requestIdHeader = requestId ? { 'X-Request-Id': requestId } : undefined;
|
|
55
|
-
const headers = Object.assign(Object.assign(Object.assign(Object.assign({}, defaultHeaders), authHeader), requestIdHeader), customHeaders);
|
|
56
|
-
return { baseURL, headers };
|
|
57
|
-
}
|
|
58
|
-
function getHttpClientConfig(args) {
|
|
59
|
-
const { baseURL, apiToken, requestId, customHeaders } = args;
|
|
60
|
-
const configuration = getRequestConfiguration({ baseURL, apiToken, requestId, customHeaders });
|
|
61
|
-
return Object.assign(Object.assign({}, configuration), { timeout: 30000, retry: {
|
|
62
|
-
retries: 3,
|
|
63
|
-
retryCondition: http_1.isNetworkError,
|
|
64
|
-
retryDelay: getRetryDelay,
|
|
65
|
-
} });
|
|
66
|
-
}
|
|
67
|
-
function isSuccess(response) {
|
|
68
|
-
return response.status >= 200 && response.status < 300;
|
|
69
|
-
}
|
|
70
|
-
async function request(args) {
|
|
71
|
-
const { httpMethod, baseUri, relativePath, apiToken, payload, requestId: initialRequestId, hasSyncCommands, customHeaders, customFetch, } = args;
|
|
72
|
-
// Capture original stack for better error reporting
|
|
73
|
-
const originalStack = new Error();
|
|
74
|
-
try {
|
|
75
|
-
let requestId = initialRequestId;
|
|
76
|
-
// Sync api don't allow a request id in the CORS
|
|
77
|
-
if (httpMethod === 'POST' && !requestId && !baseUri.includes(endpoints_1.API_BASE_URI)) {
|
|
78
|
-
requestId = (0, uuid_1.v4)();
|
|
79
|
-
}
|
|
80
|
-
const config = getHttpClientConfig({ baseURL: baseUri, apiToken, requestId, customHeaders });
|
|
81
|
-
const url = `${baseUri}${relativePath}`;
|
|
82
|
-
const fetchOptions = {
|
|
83
|
-
method: httpMethod,
|
|
84
|
-
headers: config.headers,
|
|
85
|
-
timeout: config.timeout,
|
|
86
|
-
};
|
|
87
|
-
let finalUrl = url;
|
|
88
|
-
switch (httpMethod) {
|
|
89
|
-
case 'GET':
|
|
90
|
-
// For GET requests, add query parameters to URL
|
|
91
|
-
if (payload) {
|
|
92
|
-
// Convert payload from camelCase to snake_case
|
|
93
|
-
const convertedPayload = (0, case_conversion_1.snakeCaseKeys)(payload);
|
|
94
|
-
const queryString = paramsSerializer(convertedPayload);
|
|
95
|
-
if (queryString) {
|
|
96
|
-
const separator = url.includes('?') ? '&' : '?';
|
|
97
|
-
finalUrl = `${url}${separator}${queryString}`;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
break;
|
|
101
|
-
case 'POST':
|
|
102
|
-
case 'PUT':
|
|
103
|
-
case 'DELETE': {
|
|
104
|
-
// Convert payload from camelCase to snake_case
|
|
105
|
-
// Note: While DELETE with body is uncommon, the Todoist API uses it for some endpoints
|
|
106
|
-
if (payload) {
|
|
107
|
-
const convertedPayload = (0, case_conversion_1.snakeCaseKeys)(payload);
|
|
108
|
-
const body = hasSyncCommands
|
|
109
|
-
? JSON.stringify(convertedPayload)
|
|
110
|
-
: JSON.stringify(convertedPayload);
|
|
111
|
-
fetchOptions.body = body;
|
|
112
|
-
}
|
|
113
|
-
break;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
// Make the request
|
|
117
|
-
const response = await (0, fetch_with_retry_1.fetchWithRetry)({
|
|
118
|
-
url: finalUrl,
|
|
119
|
-
options: fetchOptions,
|
|
120
|
-
retryConfig: config.retry,
|
|
121
|
-
customFetch,
|
|
122
|
-
});
|
|
123
|
-
// Convert snake_case response to camelCase
|
|
124
|
-
const convertedData = (0, case_conversion_1.camelCaseKeys)(response.data);
|
|
125
|
-
return Object.assign(Object.assign({}, response), { data: convertedData });
|
|
126
|
-
}
|
|
127
|
-
catch (error) {
|
|
128
|
-
if (!(error instanceof Error)) {
|
|
129
|
-
throw new Error('An unknown error occurred during the request');
|
|
130
|
-
}
|
|
131
|
-
throw getTodoistRequestError({ error, originalStack });
|
|
132
|
-
}
|
|
133
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.getDefaultDispatcher = getDefaultDispatcher;
|
|
37
|
-
exports.resetDefaultDispatcherForTests = resetDefaultDispatcherForTests;
|
|
38
|
-
// Use effectively-disabled keep-alive so short-lived CLI processes do not stay
|
|
39
|
-
// open waiting on idle sockets. Undici requires positive values, so we use 1ms.
|
|
40
|
-
const KEEP_ALIVE_OPTIONS = {
|
|
41
|
-
keepAliveTimeout: 1,
|
|
42
|
-
keepAliveMaxTimeout: 1,
|
|
43
|
-
};
|
|
44
|
-
let defaultDispatcherPromise;
|
|
45
|
-
function getDefaultDispatcher() {
|
|
46
|
-
if (!isNodeEnvironment()) {
|
|
47
|
-
return Promise.resolve(undefined);
|
|
48
|
-
}
|
|
49
|
-
if (!defaultDispatcherPromise) {
|
|
50
|
-
defaultDispatcherPromise = createDefaultDispatcher().catch((error) => {
|
|
51
|
-
defaultDispatcherPromise = undefined;
|
|
52
|
-
throw error;
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
return defaultDispatcherPromise;
|
|
56
|
-
}
|
|
57
|
-
async function resetDefaultDispatcherForTests() {
|
|
58
|
-
if (!defaultDispatcherPromise) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
const dispatcherPromise = defaultDispatcherPromise;
|
|
62
|
-
defaultDispatcherPromise = undefined;
|
|
63
|
-
await dispatcherPromise.then((dispatcher) => dispatcher.close(), () => undefined);
|
|
64
|
-
}
|
|
65
|
-
async function createDefaultDispatcher() {
|
|
66
|
-
const { EnvHttpProxyAgent } = await Promise.resolve().then(() => __importStar(require('undici')));
|
|
67
|
-
return new EnvHttpProxyAgent(KEEP_ALIVE_OPTIONS);
|
|
68
|
-
}
|
|
69
|
-
function isNodeEnvironment() {
|
|
70
|
-
var _a;
|
|
71
|
-
return typeof process !== 'undefined' && Boolean((_a = process.versions) === null || _a === void 0 ? void 0 : _a.node);
|
|
72
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./types"), exports);
|
|
18
|
-
__exportStar(require("./requests"), exports);
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ActivityEventSchema = exports.ActivityEventExtraDataSchema = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
/**
|
|
6
|
-
* Flexible object containing event-specific data.
|
|
7
|
-
* Uses z.record to accept any properties for forward compatibility.
|
|
8
|
-
*/
|
|
9
|
-
exports.ActivityEventExtraDataSchema = zod_1.z.record(zod_1.z.string(), zod_1.z.any()).nullable();
|
|
10
|
-
/**
|
|
11
|
-
* Activity log event schema. Accepts unknown fields for forward compatibility.
|
|
12
|
-
*/
|
|
13
|
-
exports.ActivityEventSchema = zod_1.z
|
|
14
|
-
.object({
|
|
15
|
-
objectType: zod_1.z.string(),
|
|
16
|
-
objectId: zod_1.z.string(),
|
|
17
|
-
eventType: zod_1.z.string(),
|
|
18
|
-
eventDate: zod_1.z.string(),
|
|
19
|
-
id: zod_1.z
|
|
20
|
-
.union([zod_1.z.string(), zod_1.z.number()])
|
|
21
|
-
.transform((val) => { var _a; return (_a = val === null || val === void 0 ? void 0 : val.toString()) !== null && _a !== void 0 ? _a : null; })
|
|
22
|
-
.nullable(),
|
|
23
|
-
parentProjectId: zod_1.z.string().nullable(),
|
|
24
|
-
parentItemId: zod_1.z.string().nullable(),
|
|
25
|
-
initiatorId: zod_1.z.string().nullable(),
|
|
26
|
-
extraData: exports.ActivityEventExtraDataSchema,
|
|
27
|
-
})
|
|
28
|
-
.catchall(zod_1.z.any());
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./types"), exports);
|
|
18
|
-
__exportStar(require("./requests"), exports);
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./types"), exports);
|
|
18
|
-
__exportStar(require("./requests"), exports);
|
|
@@ -1,60 +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.CommentSchema = exports.RawCommentSchema = exports.AttachmentSchema = exports.UPLOAD_STATES = void 0;
|
|
15
|
-
const zod_1 = require("zod");
|
|
16
|
-
/** Available file attachment upload states. */
|
|
17
|
-
exports.UPLOAD_STATES = ['pending', 'completed'];
|
|
18
|
-
exports.AttachmentSchema = zod_1.z
|
|
19
|
-
.object({
|
|
20
|
-
resourceType: zod_1.z.string(),
|
|
21
|
-
})
|
|
22
|
-
.extend({
|
|
23
|
-
fileName: zod_1.z.string().nullable().optional(),
|
|
24
|
-
fileSize: zod_1.z.number().int().nullable().optional(),
|
|
25
|
-
fileType: zod_1.z.string().nullable().optional(),
|
|
26
|
-
fileUrl: zod_1.z.string().nullable().optional(),
|
|
27
|
-
fileDuration: zod_1.z.number().int().nullable().optional(),
|
|
28
|
-
uploadState: zod_1.z.enum(exports.UPLOAD_STATES).nullable().optional(),
|
|
29
|
-
image: zod_1.z.string().nullable().optional(),
|
|
30
|
-
imageWidth: zod_1.z.number().int().nullable().optional(),
|
|
31
|
-
imageHeight: zod_1.z.number().int().nullable().optional(),
|
|
32
|
-
url: zod_1.z.string().nullable().optional(),
|
|
33
|
-
title: zod_1.z.string().nullable().optional(),
|
|
34
|
-
});
|
|
35
|
-
exports.RawCommentSchema = zod_1.z
|
|
36
|
-
.object({
|
|
37
|
-
id: zod_1.z.string(),
|
|
38
|
-
itemId: zod_1.z.string().optional(),
|
|
39
|
-
projectId: zod_1.z.string().optional(),
|
|
40
|
-
content: zod_1.z.string(),
|
|
41
|
-
postedAt: zod_1.z.string(),
|
|
42
|
-
fileAttachment: exports.AttachmentSchema.nullable(),
|
|
43
|
-
postedUid: zod_1.z.string(),
|
|
44
|
-
uidsToNotify: zod_1.z.array(zod_1.z.string()).nullable(),
|
|
45
|
-
reactions: zod_1.z.record(zod_1.z.string(), zod_1.z.array(zod_1.z.string())).nullable(),
|
|
46
|
-
isDeleted: zod_1.z.boolean(),
|
|
47
|
-
})
|
|
48
|
-
.refine((data) => {
|
|
49
|
-
// At least one of itemId or projectId must be present
|
|
50
|
-
return ((data.itemId !== undefined && data.projectId === undefined) ||
|
|
51
|
-
(data.itemId === undefined && data.projectId !== undefined));
|
|
52
|
-
}, {
|
|
53
|
-
message: 'Exactly one of itemId or projectId must be provided',
|
|
54
|
-
});
|
|
55
|
-
exports.CommentSchema = exports.RawCommentSchema.transform((data) => {
|
|
56
|
-
const { itemId } = data, rest = __rest(data, ["itemId"]);
|
|
57
|
-
return Object.assign(Object.assign({}, rest), {
|
|
58
|
-
// Map itemId to taskId for backwards compatibility
|
|
59
|
-
taskId: itemId });
|
|
60
|
-
});
|
package/dist/cjs/types/common.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StringOrNumberSchema = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
/**
|
|
6
|
-
* Zod schema that accepts both string and number values and coerces to string.
|
|
7
|
-
* The REST API returns numeric IDs while the Sync API returns string IDs.
|
|
8
|
-
*/
|
|
9
|
-
const StringOrNumberSchema = zod_1.z.union([zod_1.z.string(), zod_1.z.number()]).transform((val) => String(val));
|
|
10
|
-
exports.StringOrNumberSchema = StringOrNumberSchema;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./requests"), exports);
|
package/dist/cjs/types/errors.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TodoistArgumentError = exports.TodoistRequestError = void 0;
|
|
4
|
-
const ts_custom_error_1 = require("ts-custom-error");
|
|
5
|
-
const authenticationErrorCodes = [401, 403];
|
|
6
|
-
class TodoistRequestError extends ts_custom_error_1.CustomError {
|
|
7
|
-
constructor(message, httpStatusCode, responseData) {
|
|
8
|
-
super(message);
|
|
9
|
-
this.message = message;
|
|
10
|
-
this.httpStatusCode = httpStatusCode;
|
|
11
|
-
this.responseData = responseData;
|
|
12
|
-
this.isAuthenticationError = () => {
|
|
13
|
-
if (!this.httpStatusCode) {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
return authenticationErrorCodes.includes(this.httpStatusCode);
|
|
17
|
-
};
|
|
18
|
-
Object.defineProperty(this, 'name', { value: 'TodoistRequestError' });
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.TodoistRequestError = TodoistRequestError;
|
|
22
|
-
class TodoistArgumentError extends ts_custom_error_1.CustomError {
|
|
23
|
-
constructor(message) {
|
|
24
|
-
super(message);
|
|
25
|
-
this.message = message;
|
|
26
|
-
Object.defineProperty(this, 'name', { value: 'TodoistArgumentError' });
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
exports.TodoistArgumentError = TodoistArgumentError;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./requests"), exports);
|