@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,88 +0,0 @@
|
|
|
1
|
-
import { beforeAll, afterEach, afterAll } from 'vitest';
|
|
2
|
-
import { setupServer } from 'msw/node';
|
|
3
|
-
import { http, HttpResponse } from 'msw';
|
|
4
|
-
// Request capture storage
|
|
5
|
-
const capturedRequests = [];
|
|
6
|
-
// Helper function to capture requests
|
|
7
|
-
export function captureRequest({ request, body }) {
|
|
8
|
-
const headers = {};
|
|
9
|
-
request.headers.forEach((value, key) => {
|
|
10
|
-
headers[key] = value;
|
|
11
|
-
});
|
|
12
|
-
capturedRequests.push({
|
|
13
|
-
url: request.url,
|
|
14
|
-
method: request.method,
|
|
15
|
-
headers,
|
|
16
|
-
body,
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
// Helper function to get the last captured request
|
|
20
|
-
export function getLastRequest() {
|
|
21
|
-
return capturedRequests[capturedRequests.length - 1];
|
|
22
|
-
}
|
|
23
|
-
// Helper function to get all captured requests
|
|
24
|
-
export function getAllRequests() {
|
|
25
|
-
return [...capturedRequests];
|
|
26
|
-
}
|
|
27
|
-
// Helper function to clear captured requests
|
|
28
|
-
export function clearCapturedRequests() {
|
|
29
|
-
capturedRequests.length = 0;
|
|
30
|
-
}
|
|
31
|
-
// Default handlers for common API responses
|
|
32
|
-
export const handlers = [
|
|
33
|
-
// Default handlers can be added here for common endpoints
|
|
34
|
-
// Individual test files will add their own specific handlers
|
|
35
|
-
];
|
|
36
|
-
// Create MSW server instance
|
|
37
|
-
export const server = setupServer(...handlers);
|
|
38
|
-
// Helper to create a resolver function for MSW handlers
|
|
39
|
-
function createResolver(data, status, headers) {
|
|
40
|
-
return async function resolver({ request }) {
|
|
41
|
-
let body = undefined;
|
|
42
|
-
if (request.method !== 'GET') {
|
|
43
|
-
try {
|
|
44
|
-
body = await request.json();
|
|
45
|
-
}
|
|
46
|
-
catch (_a) {
|
|
47
|
-
// Body might not be JSON
|
|
48
|
-
try {
|
|
49
|
-
body = await request.text();
|
|
50
|
-
}
|
|
51
|
-
catch (_b) {
|
|
52
|
-
// Body might be FormData or not parseable
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
captureRequest({ request, body });
|
|
57
|
-
return HttpResponse.json(data, {
|
|
58
|
-
status,
|
|
59
|
-
headers,
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
// Helper to mock a successful API response
|
|
64
|
-
export function mockApiResponse({ endpoint, data, options = {}, }) {
|
|
65
|
-
const { status = 200, method = 'GET', headers = {} } = options;
|
|
66
|
-
const resolver = createResolver(data, status, headers);
|
|
67
|
-
const httpMethod = method.toLowerCase();
|
|
68
|
-
server.use(http[httpMethod](endpoint, resolver));
|
|
69
|
-
}
|
|
70
|
-
// Helper to mock an error response
|
|
71
|
-
export function mockApiError({ endpoint, data, status, options = {}, }) {
|
|
72
|
-
mockApiResponse({ endpoint, data, options: Object.assign(Object.assign({}, options), { status }) });
|
|
73
|
-
}
|
|
74
|
-
// Setup MSW for tests
|
|
75
|
-
beforeAll(() => {
|
|
76
|
-
server.listen({
|
|
77
|
-
onUnhandledRequest: 'error', // Throw errors for unhandled requests to catch unexpected fetch calls
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
afterEach(() => {
|
|
81
|
-
server.resetHandlers(); // Reset handlers between tests
|
|
82
|
-
clearCapturedRequests(); // Clear captured requests between tests
|
|
83
|
-
});
|
|
84
|
-
afterAll(() => {
|
|
85
|
-
server.close(); // Clean up after all tests
|
|
86
|
-
});
|
|
87
|
-
// Export MSW utilities for use in tests
|
|
88
|
-
export { http, HttpResponse };
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a CustomFetch adapter for Obsidian's requestUrl API.
|
|
3
|
-
*
|
|
4
|
-
* This adapter bridges the gap between Obsidian's requestUrl interface and the
|
|
5
|
-
* standard fetch-like interface expected by the Todoist API SDK.
|
|
6
|
-
*
|
|
7
|
-
* Key differences handled by this adapter:
|
|
8
|
-
* - Obsidian returns response data as properties (response.json, response.text)
|
|
9
|
-
* while the SDK expects methods (response.json(), response.text())
|
|
10
|
-
* - Obsidian's requestUrl bypasses CORS restrictions that would block standard fetch
|
|
11
|
-
* - Obsidian throws on HTTP errors by default; we set throw: false to handle manually
|
|
12
|
-
* - Obsidian doesn't provide statusText; we default to empty string
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```typescript
|
|
16
|
-
* import { requestUrl } from 'obsidian';
|
|
17
|
-
* import { createObsidianFetchAdapter } from './obsidian-fetch-adapter.js';
|
|
18
|
-
*
|
|
19
|
-
* const api = new TodoistApi('your-token', {
|
|
20
|
-
* customFetch: createObsidianFetchAdapter(requestUrl)
|
|
21
|
-
* });
|
|
22
|
-
* ```
|
|
23
|
-
*
|
|
24
|
-
* @param requestUrl - The Obsidian requestUrl function
|
|
25
|
-
* @returns A CustomFetch function compatible with the Todoist API SDK
|
|
26
|
-
*/
|
|
27
|
-
export function createObsidianFetchAdapter(requestUrl) {
|
|
28
|
-
return async (url, options) => {
|
|
29
|
-
// Build the request parameters in Obsidian's format
|
|
30
|
-
const requestParams = {
|
|
31
|
-
url,
|
|
32
|
-
method: (options === null || options === void 0 ? void 0 : options.method) || 'GET',
|
|
33
|
-
headers: options === null || options === void 0 ? void 0 : options.headers,
|
|
34
|
-
body: options === null || options === void 0 ? void 0 : options.body,
|
|
35
|
-
throw: false, // Don't throw on HTTP errors; let the SDK handle status codes
|
|
36
|
-
};
|
|
37
|
-
// Make the request using Obsidian's requestUrl
|
|
38
|
-
const response = await requestUrl(requestParams);
|
|
39
|
-
// Transform Obsidian's response format to match CustomFetchResponse interface
|
|
40
|
-
return {
|
|
41
|
-
ok: response.status >= 200 && response.status < 300,
|
|
42
|
-
status: response.status,
|
|
43
|
-
statusText: '', // Obsidian doesn't provide statusText
|
|
44
|
-
headers: response.headers,
|
|
45
|
-
// Wrap Obsidian's direct properties as methods returning promises
|
|
46
|
-
text: () => Promise.resolve(response.text),
|
|
47
|
-
json: () => Promise.resolve(response.json),
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
}
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
import { getProjectUrl, getTaskUrl, getSectionUrl } from '../utils/url-helpers.js';
|
|
2
|
-
export const DEFAULT_TASK_ID = '1234';
|
|
3
|
-
export const DEFAULT_TASK_CONTENT = 'This is a task';
|
|
4
|
-
export const DEFAULT_TASK_DESCRIPTION = 'A description';
|
|
5
|
-
export const DEFAULT_TASK_PRIORITY = 1;
|
|
6
|
-
export const DEFAULT_ORDER = 3;
|
|
7
|
-
export const DEFAULT_PROJECT_ID = '123';
|
|
8
|
-
export const DEFAULT_PROJECT_NAME = 'This is a project';
|
|
9
|
-
export const DEFAULT_PROJECT_VIEW_STYLE = 'list';
|
|
10
|
-
const DEFAULT_LABEL_ID = '456';
|
|
11
|
-
const DEFAULT_LABEL_NAME = 'This is a label';
|
|
12
|
-
const DEFAULT_SECTION_ID = '456';
|
|
13
|
-
const DEFAULT_SECTION_NAME = 'This is a section';
|
|
14
|
-
const DEFAULT_PARENT_ID = '5678';
|
|
15
|
-
const DEFAULT_ASSIGNEE = '1234';
|
|
16
|
-
const DEFAULT_CREATOR = '1234';
|
|
17
|
-
const DEFAULT_DATE = '2020-09-08T12:00:00Z';
|
|
18
|
-
const DEFAULT_ENTITY_COLOR = 'berry_red';
|
|
19
|
-
const DEFAULT_LABELS = ['personal', 'work', 'hobby'];
|
|
20
|
-
const DEFAULT_USER_ID = '5';
|
|
21
|
-
const DEFAULT_USER_NAME = 'A User';
|
|
22
|
-
const DEFAULT_USER_EMAIL = 'atestuser@doist.com';
|
|
23
|
-
const DEFAULT_COMMENT_ID = '4';
|
|
24
|
-
const DEFAULT_COMMENT_CONTENT = 'A comment';
|
|
25
|
-
const DEFAULT_COMMENT_REACTIONS = { '👍': ['1234', '5678'] };
|
|
26
|
-
const DEFAULT_CAN_ASSIGN_TASKS = true;
|
|
27
|
-
const DEFAULT_IS_ARCHIVED = false;
|
|
28
|
-
const DEFAULT_IS_DELETED = false;
|
|
29
|
-
const DEFAULT_IS_FROZEN = false;
|
|
30
|
-
const DEFAULT_IS_COLLAPSED = false;
|
|
31
|
-
// URL constants using the helper functions
|
|
32
|
-
const DEFAULT_TASK_URL = getTaskUrl(DEFAULT_TASK_ID, DEFAULT_TASK_CONTENT);
|
|
33
|
-
const DEFAULT_PROJECT_URL = getProjectUrl(DEFAULT_PROJECT_ID, DEFAULT_PROJECT_NAME);
|
|
34
|
-
const DEFAULT_SECTION_URL = getSectionUrl(DEFAULT_SECTION_ID, DEFAULT_SECTION_NAME);
|
|
35
|
-
export const DEFAULT_AUTH_TOKEN = 'AToken';
|
|
36
|
-
export const DEFAULT_REQUEST_ID = 'ARequestID';
|
|
37
|
-
export const INVALID_ENTITY_ID = 1234;
|
|
38
|
-
export const DEFAULT_DUE_DATE = {
|
|
39
|
-
isRecurring: false,
|
|
40
|
-
string: 'a date string',
|
|
41
|
-
date: DEFAULT_DATE,
|
|
42
|
-
lang: 'en',
|
|
43
|
-
timezone: null,
|
|
44
|
-
};
|
|
45
|
-
export const DEFAULT_DURATION = {
|
|
46
|
-
amount: 10,
|
|
47
|
-
unit: 'minute',
|
|
48
|
-
};
|
|
49
|
-
export const DEFAULT_DEADLINE = {
|
|
50
|
-
date: '2020-09-08',
|
|
51
|
-
lang: 'en',
|
|
52
|
-
};
|
|
53
|
-
export const DEFAULT_TASK = {
|
|
54
|
-
id: DEFAULT_TASK_ID,
|
|
55
|
-
userId: DEFAULT_CREATOR,
|
|
56
|
-
projectId: DEFAULT_PROJECT_ID,
|
|
57
|
-
sectionId: DEFAULT_SECTION_ID,
|
|
58
|
-
parentId: DEFAULT_PARENT_ID,
|
|
59
|
-
addedByUid: DEFAULT_CREATOR,
|
|
60
|
-
assignedByUid: DEFAULT_CREATOR,
|
|
61
|
-
responsibleUid: DEFAULT_ASSIGNEE,
|
|
62
|
-
labels: DEFAULT_LABELS,
|
|
63
|
-
deadline: DEFAULT_DEADLINE,
|
|
64
|
-
duration: DEFAULT_DURATION,
|
|
65
|
-
checked: false,
|
|
66
|
-
isDeleted: DEFAULT_IS_DELETED,
|
|
67
|
-
addedAt: DEFAULT_DATE,
|
|
68
|
-
completedAt: null,
|
|
69
|
-
updatedAt: DEFAULT_DATE,
|
|
70
|
-
due: DEFAULT_DUE_DATE,
|
|
71
|
-
priority: DEFAULT_TASK_PRIORITY,
|
|
72
|
-
childOrder: DEFAULT_ORDER,
|
|
73
|
-
content: DEFAULT_TASK_CONTENT,
|
|
74
|
-
description: DEFAULT_TASK_DESCRIPTION,
|
|
75
|
-
dayOrder: DEFAULT_ORDER,
|
|
76
|
-
isCollapsed: DEFAULT_IS_COLLAPSED,
|
|
77
|
-
isUncompletable: false,
|
|
78
|
-
url: DEFAULT_TASK_URL,
|
|
79
|
-
};
|
|
80
|
-
export const INVALID_TASK = Object.assign(Object.assign({}, DEFAULT_TASK), { due: '2020-01-31' });
|
|
81
|
-
export const TASK_WITH_OPTIONALS_AS_NULL = {
|
|
82
|
-
userId: DEFAULT_CREATOR,
|
|
83
|
-
id: DEFAULT_TASK_ID,
|
|
84
|
-
projectId: DEFAULT_PROJECT_ID,
|
|
85
|
-
sectionId: null,
|
|
86
|
-
parentId: null,
|
|
87
|
-
addedByUid: DEFAULT_CREATOR,
|
|
88
|
-
assignedByUid: null,
|
|
89
|
-
responsibleUid: null,
|
|
90
|
-
labels: [],
|
|
91
|
-
deadline: null,
|
|
92
|
-
duration: null,
|
|
93
|
-
checked: false,
|
|
94
|
-
isDeleted: DEFAULT_IS_DELETED,
|
|
95
|
-
addedAt: DEFAULT_DATE,
|
|
96
|
-
completedAt: null,
|
|
97
|
-
updatedAt: DEFAULT_DATE,
|
|
98
|
-
due: null,
|
|
99
|
-
priority: DEFAULT_TASK_PRIORITY,
|
|
100
|
-
childOrder: DEFAULT_ORDER,
|
|
101
|
-
content: DEFAULT_TASK_CONTENT,
|
|
102
|
-
description: DEFAULT_TASK_DESCRIPTION,
|
|
103
|
-
dayOrder: DEFAULT_ORDER,
|
|
104
|
-
isCollapsed: DEFAULT_IS_COLLAPSED,
|
|
105
|
-
isUncompletable: false,
|
|
106
|
-
url: DEFAULT_TASK_URL,
|
|
107
|
-
};
|
|
108
|
-
export const DEFAULT_PROJECT = {
|
|
109
|
-
id: DEFAULT_PROJECT_ID,
|
|
110
|
-
name: DEFAULT_PROJECT_NAME,
|
|
111
|
-
color: DEFAULT_ENTITY_COLOR,
|
|
112
|
-
childOrder: DEFAULT_ORDER,
|
|
113
|
-
parentId: DEFAULT_PROJECT_ID,
|
|
114
|
-
isFavorite: false,
|
|
115
|
-
isShared: false,
|
|
116
|
-
inboxProject: false,
|
|
117
|
-
viewStyle: DEFAULT_PROJECT_VIEW_STYLE,
|
|
118
|
-
canAssignTasks: DEFAULT_CAN_ASSIGN_TASKS,
|
|
119
|
-
isArchived: DEFAULT_IS_ARCHIVED,
|
|
120
|
-
isDeleted: DEFAULT_IS_DELETED,
|
|
121
|
-
isFrozen: DEFAULT_IS_FROZEN,
|
|
122
|
-
createdAt: DEFAULT_DATE,
|
|
123
|
-
updatedAt: DEFAULT_DATE,
|
|
124
|
-
defaultOrder: DEFAULT_ORDER,
|
|
125
|
-
description: '',
|
|
126
|
-
isCollapsed: DEFAULT_IS_COLLAPSED,
|
|
127
|
-
url: DEFAULT_PROJECT_URL,
|
|
128
|
-
};
|
|
129
|
-
export const INVALID_PROJECT = Object.assign(Object.assign({}, DEFAULT_PROJECT), { name: 123 });
|
|
130
|
-
export const PROJECT_WITH_OPTIONALS_AS_NULL = Object.assign(Object.assign({}, DEFAULT_PROJECT), { parentId: null });
|
|
131
|
-
export const DEFAULT_SECTION = {
|
|
132
|
-
id: DEFAULT_SECTION_ID,
|
|
133
|
-
userId: DEFAULT_USER_ID,
|
|
134
|
-
projectId: DEFAULT_PROJECT_ID,
|
|
135
|
-
addedAt: '2025-03-28T14:01:23.334881Z',
|
|
136
|
-
updatedAt: '2025-03-28T14:01:23.334885Z',
|
|
137
|
-
archivedAt: null,
|
|
138
|
-
name: DEFAULT_SECTION_NAME,
|
|
139
|
-
sectionOrder: DEFAULT_ORDER,
|
|
140
|
-
isArchived: false,
|
|
141
|
-
isDeleted: false,
|
|
142
|
-
isCollapsed: false,
|
|
143
|
-
url: DEFAULT_SECTION_URL,
|
|
144
|
-
};
|
|
145
|
-
export const INVALID_SECTION = Object.assign(Object.assign({}, DEFAULT_SECTION), { projectId: undefined });
|
|
146
|
-
export const DEFAULT_LABEL = {
|
|
147
|
-
id: DEFAULT_LABEL_ID,
|
|
148
|
-
name: DEFAULT_LABEL_NAME,
|
|
149
|
-
color: DEFAULT_ENTITY_COLOR,
|
|
150
|
-
order: DEFAULT_ORDER,
|
|
151
|
-
isFavorite: false,
|
|
152
|
-
};
|
|
153
|
-
export const INVALID_LABEL = Object.assign(Object.assign({}, DEFAULT_LABEL), { isFavorite: 'true' });
|
|
154
|
-
export const DEFAULT_USER = {
|
|
155
|
-
id: DEFAULT_USER_ID,
|
|
156
|
-
name: DEFAULT_USER_NAME,
|
|
157
|
-
email: DEFAULT_USER_EMAIL,
|
|
158
|
-
};
|
|
159
|
-
export const INVALID_USER = Object.assign(Object.assign({}, DEFAULT_USER), { email: undefined });
|
|
160
|
-
export const DEFAULT_ATTACHMENT = {
|
|
161
|
-
resourceType: 'file',
|
|
162
|
-
fileType: 'image/png',
|
|
163
|
-
fileUrl: 'https://someurl.com/image.jpg',
|
|
164
|
-
uploadState: 'completed',
|
|
165
|
-
};
|
|
166
|
-
export const INVALID_ATTACHMENT = Object.assign(Object.assign({}, DEFAULT_ATTACHMENT), { uploadState: 'something random' });
|
|
167
|
-
export const DEFAULT_RAW_COMMENT = {
|
|
168
|
-
id: DEFAULT_COMMENT_ID,
|
|
169
|
-
postedUid: DEFAULT_USER_ID,
|
|
170
|
-
content: DEFAULT_COMMENT_CONTENT,
|
|
171
|
-
fileAttachment: DEFAULT_ATTACHMENT,
|
|
172
|
-
uidsToNotify: null,
|
|
173
|
-
isDeleted: false,
|
|
174
|
-
postedAt: DEFAULT_DATE,
|
|
175
|
-
reactions: DEFAULT_COMMENT_REACTIONS,
|
|
176
|
-
itemId: DEFAULT_TASK_ID,
|
|
177
|
-
};
|
|
178
|
-
export const DEFAULT_COMMENT = Object.assign(Object.assign({}, DEFAULT_RAW_COMMENT), { taskId: DEFAULT_RAW_COMMENT.itemId, itemId: undefined });
|
|
179
|
-
export const DEFAULT_REMINDER_ID = '6XGgmFQrx44wfGHr';
|
|
180
|
-
export const DEFAULT_RELATIVE_REMINDER = {
|
|
181
|
-
id: DEFAULT_REMINDER_ID,
|
|
182
|
-
itemId: DEFAULT_TASK_ID,
|
|
183
|
-
notifyUid: DEFAULT_USER_ID,
|
|
184
|
-
isDeleted: false,
|
|
185
|
-
type: 'relative',
|
|
186
|
-
minuteOffset: 30,
|
|
187
|
-
due: DEFAULT_DUE_DATE,
|
|
188
|
-
isUrgent: false,
|
|
189
|
-
};
|
|
190
|
-
export const DEFAULT_ABSOLUTE_REMINDER = {
|
|
191
|
-
id: DEFAULT_REMINDER_ID,
|
|
192
|
-
itemId: DEFAULT_TASK_ID,
|
|
193
|
-
notifyUid: DEFAULT_USER_ID,
|
|
194
|
-
isDeleted: false,
|
|
195
|
-
type: 'absolute',
|
|
196
|
-
due: DEFAULT_DUE_DATE,
|
|
197
|
-
isUrgent: true,
|
|
198
|
-
};
|
|
199
|
-
export const DEFAULT_LOCATION_REMINDER = {
|
|
200
|
-
id: DEFAULT_REMINDER_ID,
|
|
201
|
-
itemId: DEFAULT_TASK_ID,
|
|
202
|
-
notifyUid: DEFAULT_USER_ID,
|
|
203
|
-
isDeleted: false,
|
|
204
|
-
type: 'location',
|
|
205
|
-
name: 'Aliados',
|
|
206
|
-
locLat: '41.148581',
|
|
207
|
-
locLong: '-8.610945000000015',
|
|
208
|
-
locTrigger: 'on_enter',
|
|
209
|
-
radius: 100,
|
|
210
|
-
};
|
|
211
|
-
export const INVALID_COMMENT = Object.assign(Object.assign({}, DEFAULT_RAW_COMMENT), { isDeleted: 'true' });
|
|
212
|
-
export const RAW_COMMENT_WITH_OPTIONALS_AS_NULL_TASK = Object.assign(Object.assign({}, DEFAULT_RAW_COMMENT), { fileAttachment: null, uidsToNotify: null, reactions: null });
|
|
213
|
-
export const COMMENT_WITH_OPTIONALS_AS_NULL_TASK = Object.assign(Object.assign({}, RAW_COMMENT_WITH_OPTIONALS_AS_NULL_TASK), { taskId: RAW_COMMENT_WITH_OPTIONALS_AS_NULL_TASK.itemId, itemId: undefined });
|
|
214
|
-
export const RAW_COMMENT_WITH_ATTACHMENT_WITH_OPTIONALS_AS_NULL = Object.assign(Object.assign({}, DEFAULT_RAW_COMMENT), { fileAttachment: {
|
|
215
|
-
resourceType: 'file',
|
|
216
|
-
fileName: null,
|
|
217
|
-
fileSize: null,
|
|
218
|
-
fileType: null,
|
|
219
|
-
fileDuration: null,
|
|
220
|
-
uploadState: null,
|
|
221
|
-
image: null,
|
|
222
|
-
imageWidth: null,
|
|
223
|
-
imageHeight: null,
|
|
224
|
-
url: null,
|
|
225
|
-
title: null,
|
|
226
|
-
} });
|
|
227
|
-
export const COMMENT_WITH_ATTACHMENT_WITH_OPTIONALS_AS_NULL = Object.assign(Object.assign({}, RAW_COMMENT_WITH_ATTACHMENT_WITH_OPTIONALS_AS_NULL), { taskId: RAW_COMMENT_WITH_ATTACHMENT_WITH_OPTIONALS_AS_NULL.itemId, itemId: undefined });
|
|
228
|
-
export const RAW_COMMENT_WITH_OPTIONALS_AS_NULL_PROJECT = Object.assign(Object.assign({}, DEFAULT_RAW_COMMENT), { itemId: undefined, projectId: DEFAULT_PROJECT_ID });
|
|
229
|
-
export const COMMENT_WITH_OPTIONALS_AS_NULL_PROJECT = Object.assign(Object.assign({}, RAW_COMMENT_WITH_OPTIONALS_AS_NULL_PROJECT), { taskId: undefined });
|
|
230
|
-
export const DEFAULT_FOLDER = {
|
|
231
|
-
id: '789',
|
|
232
|
-
name: 'This is a folder',
|
|
233
|
-
workspaceId: '100',
|
|
234
|
-
defaultOrder: 3,
|
|
235
|
-
childOrder: 3,
|
|
236
|
-
isDeleted: false,
|
|
237
|
-
};
|