@todoist/sdk 0.0.1 → 18.0.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/LICENSE +21 -0
- package/README.md +293 -29
- package/dist/esm/authentication.js +307 -0
- package/dist/esm/clients/activity-client.js +60 -0
- package/dist/esm/clients/app-client.js +366 -0
- package/dist/esm/clients/backup-client.js +47 -0
- package/dist/esm/clients/base-client.js +29 -0
- package/dist/esm/clients/billing-client.js +160 -0
- package/dist/esm/clients/comment-client.js +92 -0
- package/dist/esm/clients/email-client.js +41 -0
- package/dist/esm/clients/filter-client.js +26 -0
- package/dist/esm/clients/folder-client.js +80 -0
- package/dist/esm/clients/id-mapping-client.js +37 -0
- package/dist/esm/clients/insights-client.js +89 -0
- package/dist/esm/clients/label-client.js +131 -0
- package/dist/esm/clients/productivity-client.js +24 -0
- package/dist/esm/clients/project-client.js +284 -0
- package/dist/esm/clients/reminder-client.js +204 -0
- package/dist/esm/clients/section-client.js +121 -0
- package/dist/esm/clients/task-client.js +264 -0
- package/dist/esm/clients/template-client.js +89 -0
- package/dist/esm/clients/ui-extension-client.js +110 -0
- package/dist/esm/clients/upload-client.js +153 -0
- package/dist/esm/clients/view-options-client.js +21 -0
- package/dist/esm/clients/workspace-client.js +384 -0
- package/dist/esm/consts/endpoints.js +193 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/test-utils/asserts.js +8 -0
- package/dist/esm/test-utils/msw-setup.js +88 -0
- package/dist/esm/test-utils/obsidian-fetch-adapter.js +51 -0
- package/dist/esm/test-utils/test-defaults.js +367 -0
- package/dist/esm/test-utils/transport-seam.js +15 -0
- package/dist/esm/test-utils/webhook-fixtures.js +26 -0
- package/dist/esm/todoist-api.js +1757 -0
- package/dist/esm/transport/fetch-with-retry.js +216 -0
- package/dist/esm/transport/http-client.js +140 -0
- package/dist/esm/transport/http-dispatcher.js +158 -0
- package/dist/esm/transport/sync-request.js +106 -0
- package/dist/esm/types/activity/index.js +2 -0
- package/dist/esm/types/activity/requests.js +1 -0
- package/dist/esm/types/activity/types.js +45 -0
- package/dist/esm/types/apps/index.js +2 -0
- package/dist/esm/types/apps/requests.js +1 -0
- package/dist/esm/types/apps/types.js +249 -0
- package/dist/esm/types/backups/index.js +2 -0
- package/dist/esm/types/backups/requests.js +1 -0
- package/dist/esm/types/backups/types.js +5 -0
- package/dist/esm/types/billing/index.js +2 -0
- package/dist/esm/types/billing/requests.js +1 -0
- package/dist/esm/types/billing/types.js +89 -0
- package/dist/esm/types/comments/index.js +2 -0
- package/dist/esm/types/comments/requests.js +1 -0
- package/dist/esm/types/comments/types.js +57 -0
- package/dist/esm/types/common.js +7 -0
- package/dist/esm/types/emails/index.js +1 -0
- package/dist/esm/types/emails/requests.js +2 -0
- package/dist/esm/types/errors.js +41 -0
- package/dist/esm/types/folders/index.js +1 -0
- package/dist/esm/types/folders/requests.js +1 -0
- package/dist/esm/types/http.js +20 -0
- package/dist/esm/types/id-mappings/index.js +2 -0
- package/dist/esm/types/id-mappings/requests.js +17 -0
- package/dist/esm/types/id-mappings/types.js +9 -0
- package/dist/esm/types/index.js +24 -0
- package/dist/esm/types/insights/index.js +2 -0
- package/dist/esm/types/insights/requests.js +1 -0
- package/dist/esm/types/insights/types.js +77 -0
- package/dist/esm/types/labels/index.js +2 -0
- package/dist/esm/types/labels/requests.js +1 -0
- package/dist/esm/types/labels/types.js +8 -0
- package/dist/esm/types/productivity/index.js +1 -0
- package/dist/esm/types/productivity/types.js +65 -0
- package/dist/esm/types/projects/index.js +2 -0
- package/dist/esm/types/projects/requests.js +1 -0
- package/dist/esm/types/projects/types.js +65 -0
- package/dist/esm/types/reminders/index.js +1 -0
- package/dist/esm/types/reminders/requests.js +92 -0
- package/dist/esm/types/sections/index.js +2 -0
- package/dist/esm/types/sections/requests.js +1 -0
- package/dist/esm/types/sections/types.js +23 -0
- package/dist/esm/types/sync/commands/calendars.js +1 -0
- package/dist/esm/types/sync/commands/filters.js +1 -0
- package/dist/esm/types/sync/commands/folders.js +1 -0
- package/dist/esm/types/sync/commands/index.js +18 -0
- package/dist/esm/types/sync/commands/labels.js +2 -0
- package/dist/esm/types/sync/commands/notes.js +1 -0
- package/dist/esm/types/sync/commands/notifications.js +1 -0
- package/dist/esm/types/sync/commands/others.js +1 -0
- package/dist/esm/types/sync/commands/project-view-options.js +1 -0
- package/dist/esm/types/sync/commands/projects.js +1 -0
- package/dist/esm/types/sync/commands/reminders.js +1 -0
- package/dist/esm/types/sync/commands/sections.js +1 -0
- package/dist/esm/types/sync/commands/shared.js +16 -0
- package/dist/esm/types/sync/commands/sharing.js +1 -0
- package/dist/esm/types/sync/commands/tasks.js +1 -0
- package/dist/esm/types/sync/commands/view-options.js +1 -0
- package/dist/esm/types/sync/commands/workspace-filters.js +1 -0
- package/dist/esm/types/sync/commands/workspaces.js +1 -0
- package/dist/esm/types/sync/index.js +6 -0
- package/dist/esm/types/sync/request.js +1 -0
- package/dist/esm/types/sync/resource-types.js +36 -0
- package/dist/esm/types/sync/resources/calendars.js +24 -0
- package/dist/esm/types/sync/resources/collaborators.js +21 -0
- package/dist/esm/types/sync/resources/completed-info.js +21 -0
- package/dist/esm/types/sync/resources/filters.js +12 -0
- package/dist/esm/types/sync/resources/folders.js +10 -0
- package/dist/esm/types/sync/resources/index.js +18 -0
- package/dist/esm/types/sync/resources/labels.js +7 -0
- package/dist/esm/types/sync/resources/live-notifications.js +35 -0
- package/dist/esm/types/sync/resources/notes.js +18 -0
- package/dist/esm/types/sync/resources/reminders.js +58 -0
- package/dist/esm/types/sync/resources/suggestions.js +33 -0
- package/dist/esm/types/sync/resources/tooltips.js +5 -0
- package/dist/esm/types/sync/resources/user-plan-limits.js +21 -0
- package/dist/esm/types/sync/resources/user-settings.js +41 -0
- package/dist/esm/types/sync/resources/user-status.js +22 -0
- package/dist/esm/types/sync/resources/user.js +109 -0
- package/dist/esm/types/sync/resources/view-options.js +128 -0
- package/dist/esm/types/sync/resources/workspace-filters.js +17 -0
- package/dist/esm/types/sync/resources/workspaces.js +69 -0
- package/dist/esm/types/sync/response.js +57 -0
- package/dist/esm/types/sync/user-preferences.js +68 -0
- package/dist/esm/types/tasks/index.js +2 -0
- package/dist/esm/types/tasks/requests.js +1 -0
- package/dist/esm/types/tasks/types.js +56 -0
- package/dist/esm/types/templates/index.js +1 -0
- package/dist/esm/types/templates/requests.js +1 -0
- package/dist/esm/types/ui-extensions/index.js +2 -0
- package/dist/esm/types/ui-extensions/requests.js +1 -0
- package/dist/esm/types/ui-extensions/types.js +74 -0
- package/dist/esm/types/uploads/index.js +1 -0
- package/dist/esm/types/uploads/requests.js +1 -0
- package/dist/esm/types/users/index.js +1 -0
- package/dist/esm/types/users/types.js +49 -0
- package/dist/esm/types/webhooks/comments.js +93 -0
- package/dist/esm/types/webhooks/envelope.js +23 -0
- package/dist/esm/types/webhooks/filters.js +27 -0
- package/dist/esm/types/webhooks/index.js +9 -0
- package/dist/esm/types/webhooks/labels.js +51 -0
- package/dist/esm/types/webhooks/projects.js +33 -0
- package/dist/esm/types/webhooks/reminders.js +32 -0
- package/dist/esm/types/webhooks/sections.js +50 -0
- package/dist/esm/types/webhooks/tasks.js +65 -0
- package/dist/esm/types/webhooks/types.js +52 -0
- package/dist/esm/types/workspaces/index.js +2 -0
- package/dist/esm/types/workspaces/requests.js +1 -0
- package/dist/esm/types/workspaces/types.js +151 -0
- package/dist/esm/utils/activity-helpers.js +53 -0
- package/dist/esm/utils/case-conversion.js +84 -0
- package/dist/esm/utils/colors.js +145 -0
- package/dist/esm/utils/file-response.js +29 -0
- package/dist/esm/utils/filter-queries.js +231 -0
- package/dist/esm/utils/filter-query-definitions.js +2789 -0
- package/dist/esm/utils/headers.js +42 -0
- package/dist/esm/utils/index.js +11 -0
- package/dist/esm/utils/multipart-upload.js +267 -0
- package/dist/esm/utils/person-names.js +61 -0
- package/dist/esm/utils/processing-helpers.js +12 -0
- package/dist/esm/utils/project-helpers.js +29 -0
- package/dist/esm/utils/request-helpers.js +43 -0
- package/dist/esm/utils/sanitization.js +131 -0
- package/dist/esm/utils/sync-helpers.js +19 -0
- package/dist/esm/utils/task-sorting.js +280 -0
- package/dist/esm/utils/uncompletable-helpers.js +54 -0
- package/dist/esm/utils/url-helpers.js +196 -0
- package/dist/esm/utils/validators.js +102 -0
- package/dist/esm/utils/view-options.js +15 -0
- package/dist/esm/utils/webhook-parser.js +56 -0
- package/dist/types/authentication.d.ts +262 -0
- package/dist/types/clients/activity-client.d.ts +12 -0
- package/dist/types/clients/app-client.d.ts +37 -0
- package/dist/types/clients/backup-client.d.ts +14 -0
- package/dist/types/clients/base-client.d.ts +23 -0
- package/dist/types/clients/billing-client.d.ts +22 -0
- package/dist/types/clients/comment-client.d.ts +15 -0
- package/dist/types/clients/email-client.d.ts +13 -0
- package/dist/types/clients/filter-client.d.ts +10 -0
- package/dist/types/clients/folder-client.d.ts +16 -0
- package/dist/types/clients/id-mapping-client.d.ts +13 -0
- package/dist/types/clients/insights-client.d.ts +18 -0
- package/dist/types/clients/label-client.d.ts +19 -0
- package/dist/types/clients/productivity-client.d.ts +12 -0
- package/dist/types/clients/project-client.d.ts +22 -0
- package/dist/types/clients/reminder-client.d.ts +25 -0
- package/dist/types/clients/section-client.d.ts +18 -0
- package/dist/types/clients/task-client.d.ts +25 -0
- package/dist/types/clients/template-client.d.ts +17 -0
- package/dist/types/clients/ui-extension-client.d.ts +18 -0
- package/dist/types/clients/upload-client.d.ts +17 -0
- package/dist/types/clients/view-options-client.d.ts +8 -0
- package/dist/types/clients/workspace-client.d.ts +43 -0
- package/dist/types/consts/endpoints.d.ts +120 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/test-utils/asserts.d.ts +1 -0
- package/dist/types/test-utils/msw-setup.d.ts +33 -0
- package/dist/types/test-utils/obsidian-fetch-adapter.d.ts +29 -0
- package/dist/types/test-utils/test-defaults.d.ts +286 -0
- package/dist/types/test-utils/transport-seam.d.ts +1 -0
- package/dist/types/test-utils/webhook-fixtures.d.ts +13 -0
- package/dist/types/todoist-api.d.ts +1437 -0
- package/dist/types/transport/fetch-with-retry.d.ts +12 -0
- package/dist/types/transport/http-client.d.ts +25 -0
- package/dist/types/transport/http-dispatcher.d.ts +65 -0
- package/dist/types/transport/sync-request.d.ts +31 -0
- package/dist/types/types/activity/index.d.ts +2 -0
- package/dist/types/types/activity/requests.d.ts +85 -0
- package/dist/types/types/activity/types.d.ts +56 -0
- package/dist/types/types/apps/index.d.ts +2 -0
- package/dist/types/types/apps/requests.d.ts +89 -0
- package/dist/types/types/apps/types.d.ts +418 -0
- package/dist/types/types/backups/index.d.ts +2 -0
- package/dist/types/types/backups/requests.d.ts +16 -0
- package/dist/types/types/backups/types.d.ts +7 -0
- package/dist/types/types/billing/index.d.ts +2 -0
- package/dist/types/types/billing/requests.d.ts +62 -0
- package/dist/types/types/billing/types.d.ts +207 -0
- package/dist/types/types/comments/index.d.ts +2 -0
- package/dist/types/types/comments/requests.d.ts +64 -0
- package/dist/types/types/comments/types.d.ts +141 -0
- package/dist/types/types/common.d.ts +13 -0
- package/dist/types/types/emails/index.d.ts +1 -0
- package/dist/types/types/emails/requests.d.ts +30 -0
- package/dist/types/types/errors.d.ts +29 -0
- package/dist/types/types/folders/index.d.ts +1 -0
- package/dist/types/types/folders/requests.d.ts +20 -0
- package/dist/types/types/http.d.ts +104 -0
- package/dist/types/types/id-mappings/index.d.ts +2 -0
- package/dist/types/types/id-mappings/requests.d.ts +28 -0
- package/dist/types/types/id-mappings/types.d.ts +13 -0
- package/dist/types/types/index.d.ts +24 -0
- package/dist/types/types/insights/index.d.ts +2 -0
- package/dist/types/types/insights/requests.d.ts +26 -0
- package/dist/types/types/insights/types.d.ts +167 -0
- package/dist/types/types/labels/index.d.ts +2 -0
- package/dist/types/types/labels/requests.d.ts +75 -0
- package/dist/types/types/labels/types.d.ts +13 -0
- package/dist/types/types/productivity/index.d.ts +1 -0
- package/dist/types/types/productivity/types.d.ts +115 -0
- package/dist/types/types/projects/index.d.ts +2 -0
- package/dist/types/types/projects/requests.d.ts +206 -0
- package/dist/types/types/projects/types.d.ts +286 -0
- package/dist/types/types/reminders/index.d.ts +1 -0
- package/dist/types/types/reminders/requests.d.ts +205 -0
- package/dist/types/types/sections/index.d.ts +2 -0
- package/dist/types/types/sections/requests.d.ts +49 -0
- package/dist/types/types/sections/types.d.ts +70 -0
- package/dist/types/types/sync/commands/calendars.d.ts +14 -0
- package/dist/types/types/sync/commands/filters.d.ts +24 -0
- package/dist/types/types/sync/commands/folders.d.ts +20 -0
- package/dist/types/types/sync/commands/index.d.ts +167 -0
- package/dist/types/types/sync/commands/labels.d.ts +32 -0
- package/dist/types/types/sync/commands/notes.d.ts +27 -0
- package/dist/types/types/sync/commands/notifications.d.ts +10 -0
- package/dist/types/types/sync/commands/others.d.ts +61 -0
- package/dist/types/types/sync/commands/project-view-options.d.ts +13 -0
- package/dist/types/types/sync/commands/projects.d.ts +96 -0
- package/dist/types/types/sync/commands/reminders.d.ts +51 -0
- package/dist/types/types/sync/commands/sections.d.ts +36 -0
- package/dist/types/types/sync/commands/shared.d.ts +51 -0
- package/dist/types/types/sync/commands/sharing.d.ts +16 -0
- package/dist/types/types/sync/commands/tasks.d.ts +78 -0
- package/dist/types/types/sync/commands/view-options.d.ts +18 -0
- package/dist/types/types/sync/commands/workspace-filters.d.ts +25 -0
- package/dist/types/types/sync/commands/workspaces.d.ts +82 -0
- package/dist/types/types/sync/index.d.ts +6 -0
- package/dist/types/types/sync/request.d.ts +7 -0
- package/dist/types/types/sync/resource-types.d.ts +5 -0
- package/dist/types/types/sync/resources/calendars.d.ts +38 -0
- package/dist/types/types/sync/resources/collaborators.d.ts +45 -0
- package/dist/types/types/sync/resources/completed-info.d.ts +33 -0
- package/dist/types/types/sync/resources/filters.d.ts +13 -0
- package/dist/types/types/sync/resources/folders.d.ts +11 -0
- package/dist/types/types/sync/resources/index.d.ts +18 -0
- package/dist/types/types/sync/resources/labels.d.ts +12 -0
- package/dist/types/types/sync/resources/live-notifications.d.ts +32 -0
- package/dist/types/types/sync/resources/notes.d.ts +34 -0
- package/dist/types/types/sync/resources/reminders.d.ts +213 -0
- package/dist/types/types/sync/resources/suggestions.d.ts +96 -0
- package/dist/types/types/sync/resources/tooltips.d.ts +6 -0
- package/dist/types/types/sync/resources/user-plan-limits.d.ts +47 -0
- package/dist/types/types/sync/resources/user-settings.d.ts +40 -0
- package/dist/types/types/sync/resources/user-status.d.ts +46 -0
- package/dist/types/types/sync/resources/user.d.ts +151 -0
- package/dist/types/types/sync/resources/view-options.d.ts +157 -0
- package/dist/types/types/sync/resources/workspace-filters.d.ts +18 -0
- package/dist/types/types/sync/resources/workspaces.d.ts +142 -0
- package/dist/types/types/sync/response.d.ts +930 -0
- package/dist/types/types/sync/user-preferences.d.ts +39 -0
- package/dist/types/types/tasks/index.d.ts +2 -0
- package/dist/types/types/tasks/requests.d.ts +197 -0
- package/dist/types/types/tasks/types.d.ts +162 -0
- package/dist/types/types/templates/index.d.ts +1 -0
- package/dist/types/types/templates/requests.d.ts +92 -0
- package/dist/types/types/ui-extensions/index.d.ts +2 -0
- package/dist/types/types/ui-extensions/requests.d.ts +108 -0
- package/dist/types/types/ui-extensions/types.d.ts +185 -0
- package/dist/types/types/uploads/index.d.ts +1 -0
- package/dist/types/types/uploads/requests.d.ts +32 -0
- package/dist/types/types/users/index.d.ts +1 -0
- package/dist/types/types/users/types.d.ts +67 -0
- package/dist/types/types/webhooks/comments.d.ts +1600 -0
- package/dist/types/types/webhooks/envelope.d.ts +34 -0
- package/dist/types/types/webhooks/filters.d.ts +99 -0
- package/dist/types/types/webhooks/index.d.ts +9 -0
- package/dist/types/types/webhooks/labels.d.ts +160 -0
- package/dist/types/types/webhooks/projects.d.ts +365 -0
- package/dist/types/types/webhooks/reminders.d.ts +82 -0
- package/dist/types/types/webhooks/sections.d.ts +372 -0
- package/dist/types/types/webhooks/tasks.d.ts +981 -0
- package/dist/types/types/webhooks/types.d.ts +2606 -0
- package/dist/types/types/workspaces/index.d.ts +2 -0
- package/dist/types/types/workspaces/requests.d.ts +260 -0
- package/dist/types/types/workspaces/types.d.ts +266 -0
- package/dist/types/utils/activity-helpers.d.ts +28 -0
- package/dist/types/utils/case-conversion.d.ts +20 -0
- package/dist/types/utils/colors.d.ts +201 -0
- package/dist/types/utils/file-response.d.ts +15 -0
- package/dist/types/utils/filter-queries.d.ts +42 -0
- package/dist/types/utils/filter-query-definitions.d.ts +27 -0
- package/dist/types/utils/headers.d.ts +20 -0
- package/dist/types/utils/index.d.ts +15 -0
- package/dist/types/utils/multipart-upload.d.ts +58 -0
- package/dist/types/utils/person-names.d.ts +52 -0
- package/dist/types/utils/processing-helpers.d.ts +1 -0
- package/dist/types/utils/project-helpers.d.ts +21 -0
- package/dist/types/utils/request-helpers.d.ts +33 -0
- package/dist/types/utils/sanitization.d.ts +52 -0
- package/dist/types/utils/sync-helpers.d.ts +17 -0
- package/dist/types/utils/task-sorting.d.ts +46 -0
- package/dist/types/utils/uncompletable-helpers.d.ts +30 -0
- package/dist/types/utils/url-helpers.d.ts +120 -0
- package/dist/types/utils/validators.d.ts +1917 -0
- package/dist/types/utils/view-options.d.ts +11 -0
- package/dist/types/utils/webhook-parser.d.ts +48 -0
- package/package.json +87 -8
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { ENDPOINT_REST_WORKSPACES, ENDPOINT_WORKSPACE_INVITATIONS, ENDPOINT_WORKSPACE_INVITATIONS_ALL, ENDPOINT_WORKSPACE_INVITATIONS_DELETE, ENDPOINT_WORKSPACE_JOIN, ENDPOINT_WORKSPACE_LOGO, ENDPOINT_WORKSPACE_MEMBERS, ENDPOINT_WORKSPACE_PLAN_DETAILS, ENDPOINT_WORKSPACE_USERS, getWorkspaceActiveProjectsEndpoint, getWorkspaceArchivedProjectsEndpoint, getWorkspaceInvitationAcceptEndpoint, getWorkspaceInvitationRejectEndpoint, getWorkspaceInviteUsersEndpoint, getWorkspaceUserEndpoint, getWorkspaceUserTasksEndpoint, } from '../consts/endpoints.js';
|
|
13
|
+
import { isSuccess, request } from '../transport/http-client.js';
|
|
14
|
+
import { uploadMultipartFile } from '../utils/multipart-upload.js';
|
|
15
|
+
import { generatePath } from '../utils/request-helpers.js';
|
|
16
|
+
import { IdSchema, validateJoinWorkspaceResult, validateMemberActivityInfoArray, validateProject, validateWorkspace, validateWorkspaceArray, validateWorkspaceInvitation, validateWorkspaceInvitationArray, validateWorkspacePlanDetails, validateWorkspaceUserArray, validateWorkspaceUserTaskArray, } from '../utils/validators.js';
|
|
17
|
+
import { BaseClient } from './base-client.js';
|
|
18
|
+
/**
|
|
19
|
+
* Internal sub-client handling all workspace-domain endpoints —
|
|
20
|
+
* workspaces, invitations, users, plans, logos, and workspace project
|
|
21
|
+
* pagination.
|
|
22
|
+
*
|
|
23
|
+
* Instantiated by `TodoistApi`; every public workspace method on
|
|
24
|
+
* `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
|
|
25
|
+
* JSDoc.
|
|
26
|
+
*/
|
|
27
|
+
export class WorkspaceClient extends BaseClient {
|
|
28
|
+
async getWorkspaceInvitations(args, requestId) {
|
|
29
|
+
const response = await request({
|
|
30
|
+
httpMethod: 'GET',
|
|
31
|
+
baseUri: this.syncApiBase,
|
|
32
|
+
relativePath: ENDPOINT_WORKSPACE_INVITATIONS,
|
|
33
|
+
apiToken: this.authToken,
|
|
34
|
+
customFetch: this.customFetch,
|
|
35
|
+
customHeaders: this.customHeaders,
|
|
36
|
+
payload: { workspace_id: args.workspaceId },
|
|
37
|
+
requestId: requestId,
|
|
38
|
+
});
|
|
39
|
+
return response.data;
|
|
40
|
+
}
|
|
41
|
+
async getAllWorkspaceInvitations(args = {}, requestId) {
|
|
42
|
+
const queryParams = {};
|
|
43
|
+
if (args.workspaceId) {
|
|
44
|
+
queryParams.workspace_id = args.workspaceId;
|
|
45
|
+
}
|
|
46
|
+
const response = await request({
|
|
47
|
+
httpMethod: 'GET',
|
|
48
|
+
baseUri: this.syncApiBase,
|
|
49
|
+
relativePath: ENDPOINT_WORKSPACE_INVITATIONS_ALL,
|
|
50
|
+
apiToken: this.authToken,
|
|
51
|
+
customFetch: this.customFetch,
|
|
52
|
+
customHeaders: this.customHeaders,
|
|
53
|
+
payload: queryParams,
|
|
54
|
+
requestId: requestId,
|
|
55
|
+
});
|
|
56
|
+
return validateWorkspaceInvitationArray(response.data);
|
|
57
|
+
}
|
|
58
|
+
async deleteWorkspaceInvitation(args, requestId) {
|
|
59
|
+
const response = await request({
|
|
60
|
+
httpMethod: 'POST',
|
|
61
|
+
baseUri: this.syncApiBase,
|
|
62
|
+
relativePath: ENDPOINT_WORKSPACE_INVITATIONS_DELETE,
|
|
63
|
+
apiToken: this.authToken,
|
|
64
|
+
customFetch: this.customFetch,
|
|
65
|
+
customHeaders: this.customHeaders,
|
|
66
|
+
payload: {
|
|
67
|
+
workspace_id: args.workspaceId,
|
|
68
|
+
user_email: args.userEmail,
|
|
69
|
+
},
|
|
70
|
+
requestId: requestId,
|
|
71
|
+
});
|
|
72
|
+
return validateWorkspaceInvitation(response.data);
|
|
73
|
+
}
|
|
74
|
+
async acceptWorkspaceInvitation(args, requestId) {
|
|
75
|
+
const response = await request({
|
|
76
|
+
httpMethod: 'PUT',
|
|
77
|
+
baseUri: this.syncApiBase,
|
|
78
|
+
relativePath: getWorkspaceInvitationAcceptEndpoint(args.inviteCode),
|
|
79
|
+
apiToken: this.authToken,
|
|
80
|
+
customFetch: this.customFetch,
|
|
81
|
+
customHeaders: this.customHeaders,
|
|
82
|
+
requestId: requestId,
|
|
83
|
+
});
|
|
84
|
+
return validateWorkspaceInvitation(response.data);
|
|
85
|
+
}
|
|
86
|
+
async rejectWorkspaceInvitation(args, requestId) {
|
|
87
|
+
const response = await request({
|
|
88
|
+
httpMethod: 'PUT',
|
|
89
|
+
baseUri: this.syncApiBase,
|
|
90
|
+
relativePath: getWorkspaceInvitationRejectEndpoint(args.inviteCode),
|
|
91
|
+
apiToken: this.authToken,
|
|
92
|
+
customFetch: this.customFetch,
|
|
93
|
+
customHeaders: this.customHeaders,
|
|
94
|
+
requestId: requestId,
|
|
95
|
+
});
|
|
96
|
+
return validateWorkspaceInvitation(response.data);
|
|
97
|
+
}
|
|
98
|
+
async joinWorkspace(args, requestId) {
|
|
99
|
+
const response = await request({
|
|
100
|
+
httpMethod: 'POST',
|
|
101
|
+
baseUri: this.syncApiBase,
|
|
102
|
+
relativePath: ENDPOINT_WORKSPACE_JOIN,
|
|
103
|
+
apiToken: this.authToken,
|
|
104
|
+
customFetch: this.customFetch,
|
|
105
|
+
customHeaders: this.customHeaders,
|
|
106
|
+
payload: {
|
|
107
|
+
invite_code: args.inviteCode,
|
|
108
|
+
workspace_id: args.workspaceId,
|
|
109
|
+
},
|
|
110
|
+
requestId: requestId,
|
|
111
|
+
});
|
|
112
|
+
return validateJoinWorkspaceResult(response.data);
|
|
113
|
+
}
|
|
114
|
+
async uploadWorkspaceLogo(args, requestId) {
|
|
115
|
+
if (args.delete) {
|
|
116
|
+
// Delete logo
|
|
117
|
+
const data = await uploadMultipartFile({
|
|
118
|
+
baseUrl: this.syncApiBase,
|
|
119
|
+
authToken: this.authToken,
|
|
120
|
+
endpoint: ENDPOINT_WORKSPACE_LOGO,
|
|
121
|
+
file: Buffer.alloc(0), // Empty buffer for delete
|
|
122
|
+
fileName: 'delete',
|
|
123
|
+
additionalFields: {
|
|
124
|
+
workspace_id: args.workspaceId,
|
|
125
|
+
delete: true,
|
|
126
|
+
},
|
|
127
|
+
requestId: requestId,
|
|
128
|
+
customFetch: this.customFetch,
|
|
129
|
+
customHeaders: this.customHeaders,
|
|
130
|
+
});
|
|
131
|
+
return data;
|
|
132
|
+
}
|
|
133
|
+
if (!args.file) {
|
|
134
|
+
throw new Error('file is required when not deleting logo');
|
|
135
|
+
}
|
|
136
|
+
// Validate buffer is not empty if it's a Buffer
|
|
137
|
+
if (Buffer.isBuffer(args.file) && args.file.length === 0) {
|
|
138
|
+
throw new Error('Cannot upload empty image file');
|
|
139
|
+
}
|
|
140
|
+
const additionalFields = {
|
|
141
|
+
workspace_id: args.workspaceId,
|
|
142
|
+
};
|
|
143
|
+
const data = await uploadMultipartFile({
|
|
144
|
+
baseUrl: this.syncApiBase,
|
|
145
|
+
authToken: this.authToken,
|
|
146
|
+
endpoint: ENDPOINT_WORKSPACE_LOGO,
|
|
147
|
+
file: args.file,
|
|
148
|
+
fileName: args.fileName,
|
|
149
|
+
additionalFields: additionalFields,
|
|
150
|
+
requestId: requestId,
|
|
151
|
+
customFetch: this.customFetch,
|
|
152
|
+
customHeaders: this.customHeaders,
|
|
153
|
+
});
|
|
154
|
+
return data;
|
|
155
|
+
}
|
|
156
|
+
async getWorkspacePlanDetails(args, requestId) {
|
|
157
|
+
const response = await request({
|
|
158
|
+
httpMethod: 'GET',
|
|
159
|
+
baseUri: this.syncApiBase,
|
|
160
|
+
relativePath: ENDPOINT_WORKSPACE_PLAN_DETAILS,
|
|
161
|
+
apiToken: this.authToken,
|
|
162
|
+
customFetch: this.customFetch,
|
|
163
|
+
customHeaders: this.customHeaders,
|
|
164
|
+
payload: { workspace_id: args.workspaceId },
|
|
165
|
+
requestId: requestId,
|
|
166
|
+
});
|
|
167
|
+
return validateWorkspacePlanDetails(response.data);
|
|
168
|
+
}
|
|
169
|
+
async getWorkspaceUsers(args = {}, requestId) {
|
|
170
|
+
const queryParams = {};
|
|
171
|
+
if (args.workspaceId !== undefined && args.workspaceId !== null) {
|
|
172
|
+
queryParams.workspace_id = args.workspaceId;
|
|
173
|
+
}
|
|
174
|
+
if (args.cursor) {
|
|
175
|
+
queryParams.cursor = args.cursor;
|
|
176
|
+
}
|
|
177
|
+
if (args.limit) {
|
|
178
|
+
queryParams.limit = args.limit;
|
|
179
|
+
}
|
|
180
|
+
const response = await request({
|
|
181
|
+
httpMethod: 'GET',
|
|
182
|
+
baseUri: this.syncApiBase,
|
|
183
|
+
relativePath: ENDPOINT_WORKSPACE_USERS,
|
|
184
|
+
apiToken: this.authToken,
|
|
185
|
+
customFetch: this.customFetch,
|
|
186
|
+
customHeaders: this.customHeaders,
|
|
187
|
+
payload: queryParams,
|
|
188
|
+
requestId: requestId,
|
|
189
|
+
});
|
|
190
|
+
return {
|
|
191
|
+
hasMore: response.data.hasMore || false,
|
|
192
|
+
nextCursor: response.data.nextCursor,
|
|
193
|
+
workspaceUsers: validateWorkspaceUserArray(response.data.workspaceUsers || []),
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
async getWorkspaces(requestId) {
|
|
197
|
+
const response = await request({
|
|
198
|
+
httpMethod: 'GET',
|
|
199
|
+
baseUri: this.syncApiBase,
|
|
200
|
+
relativePath: ENDPOINT_REST_WORKSPACES,
|
|
201
|
+
apiToken: this.authToken,
|
|
202
|
+
customFetch: this.customFetch,
|
|
203
|
+
customHeaders: this.customHeaders,
|
|
204
|
+
requestId: requestId,
|
|
205
|
+
});
|
|
206
|
+
return validateWorkspaceArray(response.data);
|
|
207
|
+
}
|
|
208
|
+
async getWorkspace(id, requestId) {
|
|
209
|
+
IdSchema.parse(id);
|
|
210
|
+
const response = await request({
|
|
211
|
+
httpMethod: 'GET',
|
|
212
|
+
baseUri: this.syncApiBase,
|
|
213
|
+
relativePath: generatePath(ENDPOINT_REST_WORKSPACES, id),
|
|
214
|
+
apiToken: this.authToken,
|
|
215
|
+
customFetch: this.customFetch,
|
|
216
|
+
customHeaders: this.customHeaders,
|
|
217
|
+
requestId: requestId,
|
|
218
|
+
});
|
|
219
|
+
return validateWorkspace(response.data);
|
|
220
|
+
}
|
|
221
|
+
async addWorkspace(args, requestId) {
|
|
222
|
+
const response = await request({
|
|
223
|
+
httpMethod: 'POST',
|
|
224
|
+
baseUri: this.syncApiBase,
|
|
225
|
+
relativePath: ENDPOINT_REST_WORKSPACES,
|
|
226
|
+
apiToken: this.authToken,
|
|
227
|
+
customFetch: this.customFetch,
|
|
228
|
+
customHeaders: this.customHeaders,
|
|
229
|
+
payload: args,
|
|
230
|
+
requestId: requestId,
|
|
231
|
+
});
|
|
232
|
+
return validateWorkspace(response.data);
|
|
233
|
+
}
|
|
234
|
+
async updateWorkspace(id, args, requestId) {
|
|
235
|
+
IdSchema.parse(id);
|
|
236
|
+
const response = await request({
|
|
237
|
+
httpMethod: 'POST',
|
|
238
|
+
baseUri: this.syncApiBase,
|
|
239
|
+
relativePath: generatePath(ENDPOINT_REST_WORKSPACES, id),
|
|
240
|
+
apiToken: this.authToken,
|
|
241
|
+
customFetch: this.customFetch,
|
|
242
|
+
customHeaders: this.customHeaders,
|
|
243
|
+
payload: args,
|
|
244
|
+
requestId: requestId,
|
|
245
|
+
});
|
|
246
|
+
return validateWorkspace(response.data);
|
|
247
|
+
}
|
|
248
|
+
async deleteWorkspace(id, requestId) {
|
|
249
|
+
IdSchema.parse(id);
|
|
250
|
+
const response = await request({
|
|
251
|
+
httpMethod: 'DELETE',
|
|
252
|
+
baseUri: this.syncApiBase,
|
|
253
|
+
relativePath: generatePath(ENDPOINT_REST_WORKSPACES, id),
|
|
254
|
+
apiToken: this.authToken,
|
|
255
|
+
customFetch: this.customFetch,
|
|
256
|
+
customHeaders: this.customHeaders,
|
|
257
|
+
requestId: requestId,
|
|
258
|
+
});
|
|
259
|
+
return isSuccess(response);
|
|
260
|
+
}
|
|
261
|
+
async getWorkspaceMembersActivity(args, requestId) {
|
|
262
|
+
const { workspaceId } = args, queryParams = __rest(args, ["workspaceId"]);
|
|
263
|
+
const { data } = await request({
|
|
264
|
+
httpMethod: 'GET',
|
|
265
|
+
baseUri: this.syncApiBase,
|
|
266
|
+
relativePath: ENDPOINT_WORKSPACE_MEMBERS,
|
|
267
|
+
apiToken: this.authToken,
|
|
268
|
+
customFetch: this.customFetch,
|
|
269
|
+
customHeaders: this.customHeaders,
|
|
270
|
+
payload: Object.assign({ workspaceId }, queryParams),
|
|
271
|
+
requestId: requestId,
|
|
272
|
+
});
|
|
273
|
+
return {
|
|
274
|
+
members: validateMemberActivityInfoArray(data.members),
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
async getWorkspaceUserTasks(args, requestId) {
|
|
278
|
+
const { workspaceId, userId } = args, queryParams = __rest(args, ["workspaceId", "userId"]);
|
|
279
|
+
const { data } = await request({
|
|
280
|
+
httpMethod: 'GET',
|
|
281
|
+
baseUri: this.syncApiBase,
|
|
282
|
+
relativePath: getWorkspaceUserTasksEndpoint(workspaceId, userId),
|
|
283
|
+
apiToken: this.authToken,
|
|
284
|
+
customFetch: this.customFetch,
|
|
285
|
+
customHeaders: this.customHeaders,
|
|
286
|
+
payload: queryParams,
|
|
287
|
+
requestId: requestId,
|
|
288
|
+
});
|
|
289
|
+
return {
|
|
290
|
+
tasks: validateWorkspaceUserTaskArray(data.tasks),
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
async inviteWorkspaceUsers(args, requestId) {
|
|
294
|
+
const { workspaceId } = args, payload = __rest(args, ["workspaceId"]);
|
|
295
|
+
const { data } = await request({
|
|
296
|
+
httpMethod: 'POST',
|
|
297
|
+
baseUri: this.syncApiBase,
|
|
298
|
+
relativePath: getWorkspaceInviteUsersEndpoint(workspaceId),
|
|
299
|
+
apiToken: this.authToken,
|
|
300
|
+
customFetch: this.customFetch,
|
|
301
|
+
customHeaders: this.customHeaders,
|
|
302
|
+
payload: payload,
|
|
303
|
+
requestId: requestId,
|
|
304
|
+
});
|
|
305
|
+
return data;
|
|
306
|
+
}
|
|
307
|
+
async updateWorkspaceUser(args, requestId) {
|
|
308
|
+
const { workspaceId, userId } = args, payload = __rest(args, ["workspaceId", "userId"]);
|
|
309
|
+
const response = await request({
|
|
310
|
+
httpMethod: 'POST',
|
|
311
|
+
baseUri: this.syncApiBase,
|
|
312
|
+
relativePath: getWorkspaceUserEndpoint(workspaceId, userId),
|
|
313
|
+
apiToken: this.authToken,
|
|
314
|
+
customFetch: this.customFetch,
|
|
315
|
+
customHeaders: this.customHeaders,
|
|
316
|
+
payload: payload,
|
|
317
|
+
requestId: requestId,
|
|
318
|
+
});
|
|
319
|
+
return validateJoinWorkspaceResult(response.data);
|
|
320
|
+
}
|
|
321
|
+
async removeWorkspaceUser(args, requestId) {
|
|
322
|
+
const { workspaceId, userId } = args;
|
|
323
|
+
const response = await request({
|
|
324
|
+
httpMethod: 'DELETE',
|
|
325
|
+
baseUri: this.syncApiBase,
|
|
326
|
+
relativePath: getWorkspaceUserEndpoint(workspaceId, userId),
|
|
327
|
+
apiToken: this.authToken,
|
|
328
|
+
customFetch: this.customFetch,
|
|
329
|
+
customHeaders: this.customHeaders,
|
|
330
|
+
requestId: requestId,
|
|
331
|
+
});
|
|
332
|
+
return isSuccess(response);
|
|
333
|
+
}
|
|
334
|
+
async getWorkspaceActiveProjects(args, requestId) {
|
|
335
|
+
var _a;
|
|
336
|
+
const queryParams = {};
|
|
337
|
+
if (args.cursor) {
|
|
338
|
+
queryParams.cursor = args.cursor;
|
|
339
|
+
}
|
|
340
|
+
if (args.limit) {
|
|
341
|
+
queryParams.limit = args.limit;
|
|
342
|
+
}
|
|
343
|
+
const response = await request({
|
|
344
|
+
httpMethod: 'GET',
|
|
345
|
+
baseUri: this.syncApiBase,
|
|
346
|
+
relativePath: getWorkspaceActiveProjectsEndpoint(args.workspaceId),
|
|
347
|
+
apiToken: this.authToken,
|
|
348
|
+
customFetch: this.customFetch,
|
|
349
|
+
customHeaders: this.customHeaders,
|
|
350
|
+
payload: queryParams,
|
|
351
|
+
requestId: requestId,
|
|
352
|
+
});
|
|
353
|
+
// oxlint-disable-next-line no-unsafe-assignment, no-unsafe-call, no-unsafe-member-access
|
|
354
|
+
const validatedProjects = (_a = response.data.results) === null || _a === void 0 ? void 0 : _a.map((project) => validateProject(project));
|
|
355
|
+
return Object.assign(Object.assign({}, response.data), {
|
|
356
|
+
// oxlint-disable-next-line no-unsafe-assignment
|
|
357
|
+
results: validatedProjects || [] });
|
|
358
|
+
}
|
|
359
|
+
async getWorkspaceArchivedProjects(args, requestId) {
|
|
360
|
+
var _a;
|
|
361
|
+
const queryParams = {};
|
|
362
|
+
if (args.cursor) {
|
|
363
|
+
queryParams.cursor = args.cursor;
|
|
364
|
+
}
|
|
365
|
+
if (args.limit) {
|
|
366
|
+
queryParams.limit = args.limit;
|
|
367
|
+
}
|
|
368
|
+
const response = await request({
|
|
369
|
+
httpMethod: 'GET',
|
|
370
|
+
baseUri: this.syncApiBase,
|
|
371
|
+
relativePath: getWorkspaceArchivedProjectsEndpoint(args.workspaceId),
|
|
372
|
+
apiToken: this.authToken,
|
|
373
|
+
customFetch: this.customFetch,
|
|
374
|
+
customHeaders: this.customHeaders,
|
|
375
|
+
payload: queryParams,
|
|
376
|
+
requestId: requestId,
|
|
377
|
+
});
|
|
378
|
+
// oxlint-disable-next-line no-unsafe-assignment, no-unsafe-call, no-unsafe-member-access
|
|
379
|
+
const validatedProjects = (_a = response.data.results) === null || _a === void 0 ? void 0 : _a.map((project) => validateProject(project));
|
|
380
|
+
return Object.assign(Object.assign({}, response.data), {
|
|
381
|
+
// oxlint-disable-next-line no-unsafe-assignment
|
|
382
|
+
results: validatedProjects || [] });
|
|
383
|
+
}
|
|
384
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { encodePathSegment } from '../utils/request-helpers.js';
|
|
2
|
+
const BASE_URI = 'https://api.todoist.com';
|
|
3
|
+
const TODOIST_URI = 'https://todoist.com';
|
|
4
|
+
export const TODOIST_WEB_URI = 'https://app.todoist.com/app';
|
|
5
|
+
// The API version is not configurable, to ensure
|
|
6
|
+
// compatibility between the API and the client.
|
|
7
|
+
export const API_VERSION = 'v1';
|
|
8
|
+
export const API_BASE_URI = `/api/${API_VERSION}/`;
|
|
9
|
+
const API_AUTHORIZATION_BASE_URI = '/oauth/';
|
|
10
|
+
export function getSyncBaseUri(domainBase = BASE_URI) {
|
|
11
|
+
return new URL(API_BASE_URI, domainBase).toString();
|
|
12
|
+
}
|
|
13
|
+
export function getApiRootBaseUri(domainBase = BASE_URI) {
|
|
14
|
+
return new URL('/', domainBase).toString();
|
|
15
|
+
}
|
|
16
|
+
export function getAuthBaseUri(domainBase = TODOIST_URI) {
|
|
17
|
+
return new URL(API_AUTHORIZATION_BASE_URI, domainBase).toString();
|
|
18
|
+
}
|
|
19
|
+
export const ENDPOINT_REST_TASKS = 'tasks';
|
|
20
|
+
export const ENDPOINT_REST_TASKS_FILTER = ENDPOINT_REST_TASKS + '/filter';
|
|
21
|
+
export const ENDPOINT_REST_TASKS_COMPLETED_BY_COMPLETION_DATE = ENDPOINT_REST_TASKS + '/completed/by_completion_date';
|
|
22
|
+
export const ENDPOINT_REST_TASKS_COMPLETED_BY_DUE_DATE = ENDPOINT_REST_TASKS + '/completed/by_due_date';
|
|
23
|
+
export const ENDPOINT_REST_TASKS_COMPLETED_SEARCH = 'completed/search';
|
|
24
|
+
export const ENDPOINT_REST_SECTIONS = 'sections';
|
|
25
|
+
export const ENDPOINT_REST_SECTIONS_SEARCH = ENDPOINT_REST_SECTIONS + '/search';
|
|
26
|
+
export const ENDPOINT_REST_LABELS = 'labels';
|
|
27
|
+
export const ENDPOINT_REST_LABELS_SEARCH = ENDPOINT_REST_LABELS + '/search';
|
|
28
|
+
export const ENDPOINT_REST_LABELS_SHARED = ENDPOINT_REST_LABELS + '/shared';
|
|
29
|
+
export const ENDPOINT_REST_LABELS_SHARED_RENAME = ENDPOINT_REST_LABELS_SHARED + '/rename';
|
|
30
|
+
export const ENDPOINT_REST_LABELS_SHARED_REMOVE = ENDPOINT_REST_LABELS_SHARED + '/remove';
|
|
31
|
+
export const ENDPOINT_REST_COMMENTS = 'comments';
|
|
32
|
+
export const ENDPOINT_REST_REMINDERS = 'reminders';
|
|
33
|
+
export const ENDPOINT_REST_LOCATION_REMINDERS = 'location_reminders';
|
|
34
|
+
export const ENDPOINT_REST_TASK_CLOSE = 'close';
|
|
35
|
+
export const ENDPOINT_REST_TASK_REOPEN = 'reopen';
|
|
36
|
+
export const ENDPOINT_REST_TASK_MOVE = 'move';
|
|
37
|
+
export const ENDPOINT_REST_PROJECTS = 'projects';
|
|
38
|
+
export const ENDPOINT_REST_PROJECTS_SEARCH = ENDPOINT_REST_PROJECTS + '/search';
|
|
39
|
+
export const ENDPOINT_REST_PROJECTS_ARCHIVED = ENDPOINT_REST_PROJECTS + '/archived';
|
|
40
|
+
export const ENDPOINT_REST_PROJECT_COLLABORATORS = 'collaborators';
|
|
41
|
+
export const ENDPOINT_REST_USER = 'user';
|
|
42
|
+
export const ENDPOINT_REST_PRODUCTIVITY = ENDPOINT_REST_TASKS + '/completed/stats';
|
|
43
|
+
export const ENDPOINT_REST_ACTIVITIES = 'activities';
|
|
44
|
+
export const ENDPOINT_REST_UPLOADS = 'uploads';
|
|
45
|
+
export const PROJECT_ARCHIVE = 'archive';
|
|
46
|
+
export const PROJECT_UNARCHIVE = 'unarchive';
|
|
47
|
+
export const ENDPOINT_REST_PROJECTS_ARCHIVED_COUNT = ENDPOINT_REST_PROJECTS + '/archived/count';
|
|
48
|
+
export const ENDPOINT_REST_PROJECTS_PERMISSIONS = ENDPOINT_REST_PROJECTS + '/permissions';
|
|
49
|
+
export const ENDPOINT_REST_PROJECT_FULL = 'full';
|
|
50
|
+
export const ENDPOINT_REST_PROJECT_JOIN = 'join';
|
|
51
|
+
export const SECTION_ARCHIVE = 'archive';
|
|
52
|
+
export const SECTION_UNARCHIVE = 'unarchive';
|
|
53
|
+
export const ENDPOINT_REST_PROJECTS_MOVE_TO_WORKSPACE = ENDPOINT_REST_PROJECTS + '/move_to_workspace';
|
|
54
|
+
export const ENDPOINT_REST_PROJECTS_MOVE_TO_PERSONAL = ENDPOINT_REST_PROJECTS + '/move_to_personal';
|
|
55
|
+
export const ENDPOINT_REST_TASKS_COMPLETED = ENDPOINT_REST_TASKS + '/completed';
|
|
56
|
+
export const ENDPOINT_REST_TEMPLATES_FILE = 'templates/file';
|
|
57
|
+
export const ENDPOINT_REST_TEMPLATES_URL = 'templates/url';
|
|
58
|
+
export const ENDPOINT_REST_TEMPLATES_CREATE_FROM_FILE = 'templates/create_project_from_file';
|
|
59
|
+
export const ENDPOINT_REST_TEMPLATES_IMPORT_FROM_FILE = 'templates/import_into_project_from_file';
|
|
60
|
+
export const ENDPOINT_REST_TEMPLATES_IMPORT_FROM_ID = 'templates/import_into_project_from_template_id';
|
|
61
|
+
export const ENDPOINT_REST_ACCESS_TOKENS_MIGRATE = 'access_tokens/migrate_personal_token';
|
|
62
|
+
export const ENDPOINT_REST_BACKUPS = 'backups';
|
|
63
|
+
export const ENDPOINT_REST_BACKUPS_DOWNLOAD = 'backups/download';
|
|
64
|
+
export const ENDPOINT_REST_EMAILS = 'emails';
|
|
65
|
+
export const ENDPOINT_REST_ID_MAPPINGS = 'id_mappings';
|
|
66
|
+
export const ENDPOINT_REST_MOVED_IDS = 'moved_ids';
|
|
67
|
+
export const ENDPOINT_SYNC_QUICK_ADD = ENDPOINT_REST_TASKS + '/quick';
|
|
68
|
+
export const ENDPOINT_SYNC = 'sync';
|
|
69
|
+
export const ENDPOINT_AUTHORIZATION = 'authorize';
|
|
70
|
+
export const ENDPOINT_GET_TOKEN = 'access_token';
|
|
71
|
+
export const ENDPOINT_REVOKE = 'revoke';
|
|
72
|
+
export const ENDPOINT_REGISTER = 'register';
|
|
73
|
+
export const ENDPOINT_REST_FOLDERS = 'folders';
|
|
74
|
+
export const ENDPOINT_REST_FILTERS = 'filters';
|
|
75
|
+
// Workspace endpoints
|
|
76
|
+
export const ENDPOINT_REST_WORKSPACES = 'workspaces';
|
|
77
|
+
export const ENDPOINT_WORKSPACE_INVITATIONS = 'workspaces/invitations';
|
|
78
|
+
export const ENDPOINT_WORKSPACE_INVITATIONS_ALL = 'workspaces/invitations/all';
|
|
79
|
+
export const ENDPOINT_WORKSPACE_INVITATIONS_DELETE = 'workspaces/invitations/delete';
|
|
80
|
+
export const ENDPOINT_WORKSPACE_JOIN = 'workspaces/join';
|
|
81
|
+
export const ENDPOINT_WORKSPACE_LOGO = 'workspaces/logo';
|
|
82
|
+
export const ENDPOINT_WORKSPACE_PLAN_DETAILS = 'workspaces/plan_details';
|
|
83
|
+
export const ENDPOINT_WORKSPACE_USERS = 'workspaces/users';
|
|
84
|
+
// Billing endpoints
|
|
85
|
+
export const ENDPOINT_PAYMENTS_SUBSCRIPTION_INFO = 'payments/get_subscription_info';
|
|
86
|
+
export const ENDPOINT_PAYMENTS_CANCEL_PLAN = 'payments/cancel_plan_with_redirect_to_stripe';
|
|
87
|
+
export const ENDPOINT_PAYMENTS_REACTIVATE_PLAN = 'payments/reactivate_plan';
|
|
88
|
+
export const ENDPOINT_PRO_UPGRADE = 'pro/upgrade';
|
|
89
|
+
export const ENDPOINT_PRO_TRIAL = 'pro/trial';
|
|
90
|
+
export const ENDPOINT_PRO_BILLING_PORTAL = 'pro/billing_portal';
|
|
91
|
+
export const ENDPOINT_PRO_PLAN_DETAILS = 'pro/plan_details';
|
|
92
|
+
export const ENDPOINT_WORKSPACE_UPGRADE = 'workspaces/upgrade';
|
|
93
|
+
export const ENDPOINT_WORKSPACE_TRIAL = 'workspaces/trial';
|
|
94
|
+
export const ENDPOINT_WORKSPACE_BILLING_PORTAL = 'workspaces/billing_portal';
|
|
95
|
+
export const ENDPOINT_PRICES = 'prices';
|
|
96
|
+
export const ENDPOINT_PRICING = 'pricing';
|
|
97
|
+
// Workspace invitation actions (require invite_code parameter)
|
|
98
|
+
export function getWorkspaceInvitationAcceptEndpoint(inviteCode) {
|
|
99
|
+
return `workspaces/invitations/${encodePathSegment(inviteCode)}/accept`;
|
|
100
|
+
}
|
|
101
|
+
export function getWorkspaceInvitationRejectEndpoint(inviteCode) {
|
|
102
|
+
return `workspaces/invitations/${encodePathSegment(inviteCode)}/reject`;
|
|
103
|
+
}
|
|
104
|
+
// Insights endpoints
|
|
105
|
+
export function getProjectInsightsActivityStatsEndpoint(projectId) {
|
|
106
|
+
return `projects/${encodePathSegment(projectId)}/insights/activity_stats`;
|
|
107
|
+
}
|
|
108
|
+
export function getProjectInsightsHealthEndpoint(projectId) {
|
|
109
|
+
return `projects/${encodePathSegment(projectId)}/insights/health`;
|
|
110
|
+
}
|
|
111
|
+
export function getProjectInsightsHealthContextEndpoint(projectId) {
|
|
112
|
+
return `projects/${encodePathSegment(projectId)}/insights/health/context`;
|
|
113
|
+
}
|
|
114
|
+
export function getProjectInsightsProgressEndpoint(projectId) {
|
|
115
|
+
return `projects/${encodePathSegment(projectId)}/insights/progress`;
|
|
116
|
+
}
|
|
117
|
+
export function getProjectInsightsHealthAnalyzeEndpoint(projectId) {
|
|
118
|
+
return `projects/${encodePathSegment(projectId)}/insights/health/analyze`;
|
|
119
|
+
}
|
|
120
|
+
export function getWorkspaceInsightsEndpoint(workspaceId) {
|
|
121
|
+
return `workspaces/${encodePathSegment(workspaceId)}/insights`;
|
|
122
|
+
}
|
|
123
|
+
// Workspace members
|
|
124
|
+
export const ENDPOINT_WORKSPACE_MEMBERS = 'workspaces/members';
|
|
125
|
+
// Workspace user management (require workspace_id and/or user_id parameters)
|
|
126
|
+
export function getWorkspaceUserTasksEndpoint(workspaceId, userId) {
|
|
127
|
+
return `workspaces/${encodePathSegment(workspaceId)}/users/${encodePathSegment(userId)}/tasks`;
|
|
128
|
+
}
|
|
129
|
+
export function getWorkspaceInviteUsersEndpoint(workspaceId) {
|
|
130
|
+
return `workspaces/${encodePathSegment(workspaceId)}/users/invite`;
|
|
131
|
+
}
|
|
132
|
+
export function getWorkspaceUserEndpoint(workspaceId, userId) {
|
|
133
|
+
return `workspaces/${encodePathSegment(workspaceId)}/users/${encodePathSegment(userId)}`;
|
|
134
|
+
}
|
|
135
|
+
// Workspace projects (require workspace_id parameter)
|
|
136
|
+
export function getWorkspaceActiveProjectsEndpoint(workspaceId) {
|
|
137
|
+
return `workspaces/${encodePathSegment(workspaceId)}/projects/active`;
|
|
138
|
+
}
|
|
139
|
+
export function getWorkspaceArchivedProjectsEndpoint(workspaceId) {
|
|
140
|
+
return `workspaces/${encodePathSegment(workspaceId)}/projects/archived`;
|
|
141
|
+
}
|
|
142
|
+
// App management endpoints (dev:app_console scope)
|
|
143
|
+
export const ENDPOINT_REST_APPS = 'apps';
|
|
144
|
+
export const ENDPOINT_REST_APPS_INSTALLATIONS = 'apps/installations';
|
|
145
|
+
export const ENDPOINT_REST_APPS_UI_EXTENSIONS = 'apps/ui_extensions';
|
|
146
|
+
export const ENDPOINT_REST_APPS_UI_EXTENSIONS_INSTALLED = 'apps/ui_extensions/installed';
|
|
147
|
+
export const ENDPOINT_REST_USER_AUTHORIZATIONS = 'user/authorizations';
|
|
148
|
+
export const ENDPOINT_REST_USER_AUTHORIZATIONS_DELETE = 'user/authorizations/delete';
|
|
149
|
+
/** Available app icon sizes (small 60x60, medium 300x300, large 600x600). */
|
|
150
|
+
export const APP_ICON_SIZES = ['small', 'medium', 'large'];
|
|
151
|
+
export function getAppEndpoint(appId) {
|
|
152
|
+
return `apps/${encodePathSegment(appId)}`;
|
|
153
|
+
}
|
|
154
|
+
export function getAppSecretsEndpoint(appId) {
|
|
155
|
+
return `apps/${encodePathSegment(appId)}/secrets`;
|
|
156
|
+
}
|
|
157
|
+
export function getAppClientSecretEndpoint(appId) {
|
|
158
|
+
return `apps/${encodePathSegment(appId)}/client_secret`;
|
|
159
|
+
}
|
|
160
|
+
export function getAppTokensEndpoint(appId) {
|
|
161
|
+
return `apps/${encodePathSegment(appId)}/tokens`;
|
|
162
|
+
}
|
|
163
|
+
export function getAppTestTokenEndpoint(appId) {
|
|
164
|
+
return `apps/${encodePathSegment(appId)}/test_token`;
|
|
165
|
+
}
|
|
166
|
+
export function getAppDistributionTokenEndpoint(appId) {
|
|
167
|
+
return `apps/${encodePathSegment(appId)}/distribution_token`;
|
|
168
|
+
}
|
|
169
|
+
export function getAppVerificationTokenEndpoint(appId) {
|
|
170
|
+
return `apps/${encodePathSegment(appId)}/verification_token`;
|
|
171
|
+
}
|
|
172
|
+
export function getAppWebhookEndpoint(appId) {
|
|
173
|
+
return `apps/${encodePathSegment(appId)}/webhook`;
|
|
174
|
+
}
|
|
175
|
+
export function getAppIconEndpoint(appId, size) {
|
|
176
|
+
const base = `apps/${encodePathSegment(appId)}/icon`;
|
|
177
|
+
return size === 'medium' ? base : `${base}/${size}`;
|
|
178
|
+
}
|
|
179
|
+
export function getAppInstallationEndpoint(installationId) {
|
|
180
|
+
return `apps/installations/${encodePathSegment(installationId)}`;
|
|
181
|
+
}
|
|
182
|
+
export function getAppByDistributionTokenEndpoint(distributionToken) {
|
|
183
|
+
return `apps/by_distribution_token/${encodePathSegment(distributionToken)}`;
|
|
184
|
+
}
|
|
185
|
+
export function getUiExtensionEndpoint(uiExtensionId) {
|
|
186
|
+
return `apps/ui_extensions/${encodePathSegment(uiExtensionId)}`;
|
|
187
|
+
}
|
|
188
|
+
export function getUiExtensionIconEndpoint(uiExtensionId) {
|
|
189
|
+
return `apps/ui_extensions/${encodePathSegment(uiExtensionId)}/icon`;
|
|
190
|
+
}
|
|
191
|
+
export function getUiExtensionsByIntegrationEndpoint(integrationId) {
|
|
192
|
+
return `apps/ui_extensions/integration/${encodePathSegment(integrationId)}`;
|
|
193
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { http, HttpResponse } from 'msw';
|
|
2
|
+
import { setupServer } from 'msw/node';
|
|
3
|
+
import { beforeAll, afterEach, afterAll } from 'vitest';
|
|
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 };
|