@todoist/sdk 0.0.1 → 19.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 +368 -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 +255 -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 +99 -0
- package/dist/types/types/apps/types.d.ts +450 -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 +1922 -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,56 @@
|
|
|
1
|
+
import { WebhookPayloadSchema } from '../types/webhooks/types.js';
|
|
2
|
+
import { camelCaseKeys } from './case-conversion.js';
|
|
3
|
+
/**
|
|
4
|
+
* Parses an incoming webhook request body into a typed payload.
|
|
5
|
+
*
|
|
6
|
+
* The backend sends snake_case keys (e.g. `event_name`, `user_id`, `added_at`);
|
|
7
|
+
* this converts them to camelCase and validates against
|
|
8
|
+
* {@link WebhookPayloadSchema}. Event-specific `eventData` is returned as
|
|
9
|
+
* `unknown` for events that are not yet narrowed per-resource.
|
|
10
|
+
*
|
|
11
|
+
* Pass the parsed JSON body (or any unknown value) — validation throws on
|
|
12
|
+
* unexpected shape.
|
|
13
|
+
*/
|
|
14
|
+
export function parseWebhookPayload(raw) {
|
|
15
|
+
return WebhookPayloadSchema.parse(camelCaseKeys(raw));
|
|
16
|
+
}
|
|
17
|
+
const encoder = new TextEncoder();
|
|
18
|
+
function base64ToBytes(base64) {
|
|
19
|
+
const binary = atob(base64);
|
|
20
|
+
const bytes = new Uint8Array(binary.length);
|
|
21
|
+
for (let i = 0; i < binary.length; i++) {
|
|
22
|
+
bytes[i] = binary.charCodeAt(i);
|
|
23
|
+
}
|
|
24
|
+
return bytes;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Verifies a webhook request's HMAC signature.
|
|
28
|
+
*
|
|
29
|
+
* Todoist signs webhook deliveries with an HMAC-SHA256 of the raw request body
|
|
30
|
+
* using the app's `client_secret` as the key, base64-encoded in the
|
|
31
|
+
* `X-Todoist-Hmac-SHA256` header.
|
|
32
|
+
*
|
|
33
|
+
* Uses the Web Crypto API (`crypto.subtle`), which is available in Node ≥ 20,
|
|
34
|
+
* modern browsers, React Native (with polyfills), and edge runtimes. The
|
|
35
|
+
* comparison is constant-time.
|
|
36
|
+
*
|
|
37
|
+
* @returns `true` when the signature is valid, `false` otherwise. Never throws
|
|
38
|
+
* on malformed input.
|
|
39
|
+
*/
|
|
40
|
+
export async function verifyWebhookSignature({ rawBody, signature, clientSecret, }) {
|
|
41
|
+
let provided;
|
|
42
|
+
try {
|
|
43
|
+
provided = base64ToBytes(signature);
|
|
44
|
+
}
|
|
45
|
+
catch (_a) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
const key = await crypto.subtle.importKey('raw', encoder.encode(clientSecret), { name: 'HMAC', hash: 'SHA-256' }, false, ['verify']);
|
|
49
|
+
const body = typeof rawBody === 'string' ? encoder.encode(rawBody) : rawBody;
|
|
50
|
+
try {
|
|
51
|
+
return await crypto.subtle.verify('HMAC', key, provided, body);
|
|
52
|
+
}
|
|
53
|
+
catch (_b) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { CustomFetch } from './types/http.js';
|
|
2
|
+
/**
|
|
3
|
+
* Options for authentication functions
|
|
4
|
+
*/
|
|
5
|
+
export type AuthOptions = {
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
customFetch?: CustomFetch;
|
|
8
|
+
};
|
|
9
|
+
/** Available OAuth2 permission scopes. */
|
|
10
|
+
export declare const PERMISSIONS: readonly ["task:add", "data:read", "data:read_write", "data:delete", "project:delete", "backups:read", "billing:read", "billing:read_write", "dev:app_console"];
|
|
11
|
+
/**
|
|
12
|
+
* Permission scope that can be requested during OAuth2 authorization.
|
|
13
|
+
* @see {@link https://developer.todoist.com/api/v1/#tag/Authorization}
|
|
14
|
+
*/
|
|
15
|
+
export type Permission = (typeof PERMISSIONS)[number];
|
|
16
|
+
/** Supported token endpoint authentication methods for dynamic client registration. */
|
|
17
|
+
export declare const TOKEN_ENDPOINT_AUTH_METHODS: readonly ["client_secret_post", "client_secret_basic", "none"];
|
|
18
|
+
/**
|
|
19
|
+
* Authentication method used at the token endpoint.
|
|
20
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc7591#section-2 RFC 7591 Section 2}
|
|
21
|
+
*/
|
|
22
|
+
export type TokenEndpointAuthMethod = (typeof TOKEN_ENDPOINT_AUTH_METHODS)[number];
|
|
23
|
+
/**
|
|
24
|
+
* Parameters for registering a new OAuth client via Dynamic Client Registration.
|
|
25
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc7591 RFC 7591}
|
|
26
|
+
*/
|
|
27
|
+
export type ClientRegistrationRequest = {
|
|
28
|
+
redirectUris: string[];
|
|
29
|
+
clientName?: string;
|
|
30
|
+
clientUri?: string;
|
|
31
|
+
logoUri?: string;
|
|
32
|
+
scope?: readonly Permission[];
|
|
33
|
+
grantTypes?: string[];
|
|
34
|
+
responseTypes?: string[];
|
|
35
|
+
tokenEndpointAuthMethod?: TokenEndpointAuthMethod;
|
|
36
|
+
};
|
|
37
|
+
type RawClientRegistrationResponse = {
|
|
38
|
+
clientId: string;
|
|
39
|
+
clientSecret?: string;
|
|
40
|
+
clientName: string;
|
|
41
|
+
redirectUris: string[];
|
|
42
|
+
scope?: string;
|
|
43
|
+
grantTypes: string[];
|
|
44
|
+
responseTypes: string[];
|
|
45
|
+
tokenEndpointAuthMethod: string;
|
|
46
|
+
clientIdIssuedAt?: number;
|
|
47
|
+
clientSecretExpiresAt?: number;
|
|
48
|
+
clientUri?: string;
|
|
49
|
+
logoUri?: string;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Response from a successful dynamic client registration.
|
|
53
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc7591#section-3.2.1 RFC 7591 Section 3.2.1}
|
|
54
|
+
*/
|
|
55
|
+
export type ClientRegistrationResponse = Omit<RawClientRegistrationResponse, 'clientIdIssuedAt' | 'clientSecretExpiresAt' | 'scope'> & {
|
|
56
|
+
scope?: Permission[];
|
|
57
|
+
clientIdIssuedAt?: Date;
|
|
58
|
+
/** `null` indicates the client secret never expires. Absent when no secret is issued. */
|
|
59
|
+
clientSecretExpiresAt?: Date | null;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Parameters required to exchange an authorization code for an access token.
|
|
63
|
+
* @see https://developer.todoist.com/api/v1/#tag/Authorization/OAuth
|
|
64
|
+
*/
|
|
65
|
+
export type AuthTokenRequestArgs = {
|
|
66
|
+
clientId: string;
|
|
67
|
+
clientSecret: string;
|
|
68
|
+
code: string;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Response from a successful OAuth2 token exchange.
|
|
72
|
+
* @see https://developer.todoist.com/api/v1/#tag/Authorization/OAuth
|
|
73
|
+
*/
|
|
74
|
+
export type AuthTokenResponse = {
|
|
75
|
+
accessToken: string;
|
|
76
|
+
tokenType: string;
|
|
77
|
+
/**
|
|
78
|
+
* Refresh token for use with {@link refreshAuthToken}.
|
|
79
|
+
*
|
|
80
|
+
* Only present when the OAuth app has refresh tokens enabled — the default
|
|
81
|
+
* for new apps, and immutable once on. Apps without it receive a long-lived
|
|
82
|
+
* access token and no refresh token.
|
|
83
|
+
*/
|
|
84
|
+
refreshToken?: string;
|
|
85
|
+
/** Access token lifetime in seconds. */
|
|
86
|
+
expiresIn?: number;
|
|
87
|
+
/** Space-separated granted scopes, when returned. */
|
|
88
|
+
scope?: string;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Parameters required to exchange a refresh token for a new access token.
|
|
92
|
+
* @see https://developer.todoist.com/api/v1/#tag/Authorization/OAuth
|
|
93
|
+
*/
|
|
94
|
+
export type RefreshTokenRequestArgs = {
|
|
95
|
+
clientId: string;
|
|
96
|
+
/**
|
|
97
|
+
* Client secret. Required for confidential clients; omit for public clients
|
|
98
|
+
* registered with `tokenEndpointAuthMethod: 'none'`.
|
|
99
|
+
*/
|
|
100
|
+
clientSecret?: string;
|
|
101
|
+
refreshToken: string;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Parameters required to revoke a token using RFC 7009 compliant endpoint.
|
|
105
|
+
* @see https://developer.todoist.com/api/v1/#tag/Authorization
|
|
106
|
+
*/
|
|
107
|
+
export type RevokeTokenRequestArgs = {
|
|
108
|
+
clientId: string;
|
|
109
|
+
clientSecret: string;
|
|
110
|
+
token: string;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Parameters required to migrate a personal API token to an OAuth token.
|
|
114
|
+
*/
|
|
115
|
+
export type MigratePersonalTokenArgs = {
|
|
116
|
+
/** The unique Client ID of the registered Todoist application. */
|
|
117
|
+
clientId: string;
|
|
118
|
+
/** The unique Client Secret of the registered Todoist application. */
|
|
119
|
+
clientSecret: string;
|
|
120
|
+
/** The personal API token obtained from email/password authentication. */
|
|
121
|
+
personalToken: string;
|
|
122
|
+
/** Scopes for the new OAuth token. */
|
|
123
|
+
scope: readonly Permission[];
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Response from a successful personal token migration.
|
|
127
|
+
*/
|
|
128
|
+
export type MigratePersonalTokenResponse = {
|
|
129
|
+
/** The new OAuth access token, or null if migration failed. */
|
|
130
|
+
accessToken: string | null;
|
|
131
|
+
/** The token type (always 'Bearer'). */
|
|
132
|
+
tokenType: string;
|
|
133
|
+
/** Token expiration time in seconds. */
|
|
134
|
+
expiresIn: number;
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Generates a random state parameter for OAuth2 authorization.
|
|
138
|
+
* The state parameter helps prevent CSRF attacks.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```typescript
|
|
142
|
+
* const state = getAuthStateParameter()
|
|
143
|
+
* // Store state in session
|
|
144
|
+
* const authUrl = getAuthorizationUrl(clientId, ['data:read'], state)
|
|
145
|
+
* ```
|
|
146
|
+
*
|
|
147
|
+
* @returns A random UUID v4 string
|
|
148
|
+
*/
|
|
149
|
+
export declare function getAuthStateParameter(): string;
|
|
150
|
+
/**
|
|
151
|
+
* Generates the authorization URL for the OAuth2 flow.
|
|
152
|
+
*
|
|
153
|
+
* The `clientId` can be either a traditional client ID string (e.g. from
|
|
154
|
+
* {@link registerClient}) or an HTTPS URL pointing to a client metadata document,
|
|
155
|
+
* as defined in {@link https://drafts.ietf.org/doc/draft-ietf-oauth-client-id-metadata-document/ RFC draft-ietf-oauth-client-id-metadata-document}.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```typescript
|
|
159
|
+
* const url = getAuthorizationUrl({
|
|
160
|
+
* clientId: 'your-client-id',
|
|
161
|
+
* permissions: ['data:read', 'task:add'],
|
|
162
|
+
* state,
|
|
163
|
+
* })
|
|
164
|
+
* // Redirect user to url
|
|
165
|
+
* ```
|
|
166
|
+
*
|
|
167
|
+
* @returns The full authorization URL to redirect users to
|
|
168
|
+
* @see https://developer.todoist.com/api/v1/#tag/Authorization/OAuth
|
|
169
|
+
*/
|
|
170
|
+
export declare function getAuthorizationUrl({ clientId, permissions, state, baseUrl, }: {
|
|
171
|
+
clientId: string;
|
|
172
|
+
permissions: readonly Permission[];
|
|
173
|
+
state: string;
|
|
174
|
+
baseUrl?: string;
|
|
175
|
+
}): string;
|
|
176
|
+
export declare function getAuthToken(args: AuthTokenRequestArgs, options?: AuthOptions): Promise<AuthTokenResponse>;
|
|
177
|
+
/**
|
|
178
|
+
* Exchanges a refresh token for a new access token using the OAuth2
|
|
179
|
+
* `refresh_token` grant.
|
|
180
|
+
*
|
|
181
|
+
* Only relevant for OAuth apps that have refresh tokens enabled (the default for
|
|
182
|
+
* new apps). Apps without them never receive a `refreshToken` from
|
|
183
|
+
* {@link getAuthToken}, so they have nothing to pass here — their access tokens
|
|
184
|
+
* are long-lived instead.
|
|
185
|
+
*
|
|
186
|
+
* Omit `clientSecret` for public clients registered with
|
|
187
|
+
* `tokenEndpointAuthMethod: 'none'`.
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* ```typescript
|
|
191
|
+
* const { accessToken, refreshToken } = await refreshAuthToken({
|
|
192
|
+
* clientId: 'your-client-id',
|
|
193
|
+
* clientSecret: 'your-client-secret',
|
|
194
|
+
* refreshToken: storedRefreshToken,
|
|
195
|
+
* })
|
|
196
|
+
* ```
|
|
197
|
+
*
|
|
198
|
+
* @returns The refreshed token. The server rotates the refresh token, so the
|
|
199
|
+
* response carries a new `refreshToken` — persist it in place of the old one.
|
|
200
|
+
* @throws {@link TodoistRequestError} If the refresh fails
|
|
201
|
+
*/
|
|
202
|
+
export declare function refreshAuthToken(args: RefreshTokenRequestArgs, options?: AuthOptions): Promise<AuthTokenResponse>;
|
|
203
|
+
/**
|
|
204
|
+
* Revokes a token using the RFC 7009 OAuth 2.0 Token Revocation standard.
|
|
205
|
+
*
|
|
206
|
+
* This function uses HTTP Basic Authentication with client credentials and follows
|
|
207
|
+
* the RFC 7009 specification for token revocation.
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* ```typescript
|
|
211
|
+
* await revokeToken({
|
|
212
|
+
* clientId: 'your-client-id',
|
|
213
|
+
* clientSecret: 'your-client-secret',
|
|
214
|
+
* token: 'access-token-to-revoke'
|
|
215
|
+
* })
|
|
216
|
+
* ```
|
|
217
|
+
*
|
|
218
|
+
* @returns True if revocation was successful
|
|
219
|
+
* @see https://datatracker.ietf.org/doc/html/rfc7009
|
|
220
|
+
* @see https://developer.todoist.com/api/v1/#tag/Authorization
|
|
221
|
+
*/
|
|
222
|
+
export declare function revokeToken(args: RevokeTokenRequestArgs, options?: AuthOptions): Promise<boolean>;
|
|
223
|
+
/**
|
|
224
|
+
* Migrates a personal API token to an OAuth access token.
|
|
225
|
+
*
|
|
226
|
+
* This allows applications to transition users from personal API tokens
|
|
227
|
+
* to proper OAuth tokens without requiring the user to go through the
|
|
228
|
+
* full OAuth authorization flow.
|
|
229
|
+
*
|
|
230
|
+
* @example
|
|
231
|
+
* ```typescript
|
|
232
|
+
* const { accessToken } = await migratePersonalToken({
|
|
233
|
+
* clientId: 'your-client-id',
|
|
234
|
+
* clientSecret: 'your-client-secret',
|
|
235
|
+
* personalToken: 'user-personal-token',
|
|
236
|
+
* scope: 'data:read_write,data:delete'
|
|
237
|
+
* })
|
|
238
|
+
* ```
|
|
239
|
+
*
|
|
240
|
+
* @returns The new OAuth token response
|
|
241
|
+
* @throws {@link TodoistRequestError} If the migration fails
|
|
242
|
+
*/
|
|
243
|
+
export declare function migratePersonalToken(args: MigratePersonalTokenArgs, options?: AuthOptions): Promise<MigratePersonalTokenResponse>;
|
|
244
|
+
/**
|
|
245
|
+
* Registers a new OAuth client via Dynamic Client Registration (RFC 7591).
|
|
246
|
+
*
|
|
247
|
+
* @example
|
|
248
|
+
* ```typescript
|
|
249
|
+
* const client = await registerClient({
|
|
250
|
+
* redirectUris: ['https://example.com/callback'],
|
|
251
|
+
* clientName: 'My App',
|
|
252
|
+
* scope: ['data:read_write', 'task:add'],
|
|
253
|
+
* })
|
|
254
|
+
* // Use client.clientId and client.clientSecret for OAuth flows
|
|
255
|
+
* ```
|
|
256
|
+
*
|
|
257
|
+
* @returns The registered client details
|
|
258
|
+
* @throws {@link TodoistRequestError} If the registration fails
|
|
259
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc7591 RFC 7591}
|
|
260
|
+
*/
|
|
261
|
+
export declare function registerClient(args: ClientRegistrationRequest, options?: AuthOptions): Promise<ClientRegistrationResponse>;
|
|
262
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { GetActivityLogsArgs, GetActivityLogsResponse } from '../types/activity/index.js';
|
|
2
|
+
import { BaseClient } from './base-client.js';
|
|
3
|
+
/**
|
|
4
|
+
* Internal sub-client handling the activity-log endpoint.
|
|
5
|
+
*
|
|
6
|
+
* Instantiated by `TodoistApi`; the public `getActivityLogs` method on
|
|
7
|
+
* `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
|
|
8
|
+
* JSDoc.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ActivityClient extends BaseClient {
|
|
11
|
+
getActivityLogs(args?: GetActivityLogsArgs): Promise<GetActivityLogsResponse>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { AddAppArgs, App, AppByDistributionToken, AppDistributionToken, AppInstallation, AppSecrets, AppTestToken, AppVerificationToken, AppWebhook, AppWithUserCount, InstallAppArgs, RevokeUserAuthorizationArgs, UpdateAppArgs, UpdateAppInstallationArgs, UpdateAppWebhookArgs, UploadAppIconArgs, UserAuthorization } from '../types/apps/index.js';
|
|
2
|
+
import { BaseClient } from './base-client.js';
|
|
3
|
+
/**
|
|
4
|
+
* Internal sub-client handling all developer-app management endpoints
|
|
5
|
+
* (apps, secrets, tokens, webhooks, installations, user authorizations).
|
|
6
|
+
* All endpoints require the `dev:app_console` OAuth scope.
|
|
7
|
+
*
|
|
8
|
+
* Instantiated by `TodoistApi`; every public app-management method on
|
|
9
|
+
* `TodoistApi` delegates here. See `todoist-api.ts` for user-facing JSDoc.
|
|
10
|
+
*/
|
|
11
|
+
export declare class AppClient extends BaseClient {
|
|
12
|
+
getApps(requestId?: string): Promise<App[]>;
|
|
13
|
+
getApp(appId: string, requestId?: string): Promise<AppWithUserCount>;
|
|
14
|
+
addApp(args: AddAppArgs, requestId?: string): Promise<App>;
|
|
15
|
+
updateApp(appId: string, args: UpdateAppArgs, requestId?: string): Promise<AppWithUserCount>;
|
|
16
|
+
deleteApp(appId: string, requestId?: string): Promise<boolean>;
|
|
17
|
+
getAppSecrets(appId: string, requestId?: string): Promise<AppSecrets>;
|
|
18
|
+
resetAppClientSecret(appId: string, requestId?: string): Promise<AppWithUserCount>;
|
|
19
|
+
revokeAppTokens(appId: string, requestId?: string): Promise<AppWithUserCount>;
|
|
20
|
+
uploadAppIcon({ appId, file, fileName, size }: UploadAppIconArgs, requestId?: string): Promise<AppWithUserCount>;
|
|
21
|
+
getAppTestToken(appId: string, requestId?: string): Promise<AppTestToken>;
|
|
22
|
+
createAppTestToken(appId: string, requestId?: string): Promise<AppTestToken>;
|
|
23
|
+
getAppDistributionToken(appId: string, requestId?: string): Promise<AppDistributionToken>;
|
|
24
|
+
getAppVerificationToken(appId: string, requestId?: string): Promise<AppVerificationToken>;
|
|
25
|
+
resetAppVerificationToken(appId: string, requestId?: string): Promise<AppVerificationToken>;
|
|
26
|
+
getAppByDistributionToken(distributionToken: string, requestId?: string): Promise<AppByDistributionToken>;
|
|
27
|
+
getAppWebhook(appId: string, requestId?: string): Promise<AppWebhook | null>;
|
|
28
|
+
updateAppWebhook(args: UpdateAppWebhookArgs, requestId?: string): Promise<AppWebhook>;
|
|
29
|
+
deleteAppWebhook(appId: string, requestId?: string): Promise<boolean>;
|
|
30
|
+
getAppInstallations(requestId?: string): Promise<AppInstallation[]>;
|
|
31
|
+
installApp(args: InstallAppArgs, requestId?: string): Promise<AppInstallation>;
|
|
32
|
+
getAppInstallation(installationId: string, requestId?: string): Promise<AppInstallation>;
|
|
33
|
+
updateAppInstallation(installationId: string, args: UpdateAppInstallationArgs, requestId?: string): Promise<AppInstallation>;
|
|
34
|
+
uninstallApp(installationId: string, requestId?: string): Promise<boolean>;
|
|
35
|
+
getUserAuthorizations(requestId?: string): Promise<UserAuthorization[]>;
|
|
36
|
+
revokeUserAuthorization(args: RevokeUserAuthorizationArgs, requestId?: string): Promise<boolean>;
|
|
37
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Backup, DownloadBackupArgs, GetBackupsArgs } from '../types/backups/index.js';
|
|
2
|
+
import type { FileResponse } from '../types/http.js';
|
|
3
|
+
import { BaseClient } from './base-client.js';
|
|
4
|
+
/**
|
|
5
|
+
* Internal sub-client handling backup-domain endpoints.
|
|
6
|
+
*
|
|
7
|
+
* Instantiated by `TodoistApi`; every public backup method on
|
|
8
|
+
* `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
|
|
9
|
+
* JSDoc.
|
|
10
|
+
*/
|
|
11
|
+
export declare class BackupClient extends BaseClient {
|
|
12
|
+
getBackups(args?: GetBackupsArgs): Promise<Backup[]>;
|
|
13
|
+
downloadBackup(args: DownloadBackupArgs): Promise<FileResponse>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { SyncRequestContext } from '../transport/sync-request.js';
|
|
2
|
+
import type { CustomFetch, CustomHeaders } from '../types/http.js';
|
|
3
|
+
/**
|
|
4
|
+
* Internal base class for every domain sub-client (tasks, projects, …).
|
|
5
|
+
*
|
|
6
|
+
* Not exported from the package — sub-clients are an implementation detail
|
|
7
|
+
* of `TodoistApi`. Holds the pieces of HTTP identity every sub-client
|
|
8
|
+
* needs and exposes a typed accessor to feed the Sync API helper.
|
|
9
|
+
*
|
|
10
|
+
* The constructor takes a {@link SyncRequestContext} — the same record
|
|
11
|
+
* shape used by `performSyncRequest` — so there is a single type describing
|
|
12
|
+
* "the HTTP identity an SDK component needs", not two types that must stay
|
|
13
|
+
* in sync.
|
|
14
|
+
*/
|
|
15
|
+
export declare abstract class BaseClient {
|
|
16
|
+
protected readonly authToken: string;
|
|
17
|
+
protected readonly syncApiBase: string;
|
|
18
|
+
protected readonly apiRootBase: string;
|
|
19
|
+
protected readonly customFetch?: CustomFetch;
|
|
20
|
+
protected readonly customHeaders?: CustomHeaders;
|
|
21
|
+
constructor(context: SyncRequestContext);
|
|
22
|
+
protected get syncContext(): SyncRequestContext;
|
|
23
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { BillingPortalUrlResponse, CancelPlanArgs, CheckoutSessionResponse, GetPricingArgs, PricesResponse, PricingResponse, ProBillingPortalArgs, ProPlanDetails, StartProTrialArgs, StartWorkspaceTrialArgs, SubscriptionInfo, UpgradeToProArgs, UpgradeWorkspaceArgs, WorkspaceBillingPortalArgs } from '../types/billing/index.js';
|
|
2
|
+
import { BaseClient } from './base-client.js';
|
|
3
|
+
/**
|
|
4
|
+
* Internal sub-client handling all billing-domain endpoints.
|
|
5
|
+
*
|
|
6
|
+
* Instantiated by `TodoistApi`; every public billing method on `TodoistApi`
|
|
7
|
+
* delegates here. See `todoist-api.ts` for the user-facing JSDoc.
|
|
8
|
+
*/
|
|
9
|
+
export declare class BillingClient extends BaseClient {
|
|
10
|
+
getSubscriptionInfo(): Promise<SubscriptionInfo>;
|
|
11
|
+
cancelPlan(args?: CancelPlanArgs, requestId?: string): Promise<BillingPortalUrlResponse>;
|
|
12
|
+
reactivatePlan(requestId?: string): Promise<SubscriptionInfo>;
|
|
13
|
+
upgradeToPro(args: UpgradeToProArgs, requestId?: string): Promise<CheckoutSessionResponse>;
|
|
14
|
+
startProTrial(args: StartProTrialArgs, requestId?: string): Promise<CheckoutSessionResponse>;
|
|
15
|
+
createProBillingPortalSession(args: ProBillingPortalArgs, requestId?: string): Promise<BillingPortalUrlResponse>;
|
|
16
|
+
getProPlanDetails(): Promise<ProPlanDetails>;
|
|
17
|
+
upgradeWorkspace(args: UpgradeWorkspaceArgs, requestId?: string): Promise<CheckoutSessionResponse>;
|
|
18
|
+
startWorkspaceTrial(args: StartWorkspaceTrialArgs, requestId?: string): Promise<CheckoutSessionResponse>;
|
|
19
|
+
createWorkspaceBillingPortalSession(args: WorkspaceBillingPortalArgs, requestId?: string): Promise<BillingPortalUrlResponse>;
|
|
20
|
+
getPrices(): Promise<PricesResponse>;
|
|
21
|
+
getPricing(args?: GetPricingArgs): Promise<PricingResponse>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AddCommentArgs, Comment, GetCommentsResponse, GetProjectCommentsArgs, GetTaskCommentsArgs, UpdateCommentArgs } from '../types/comments/index.js';
|
|
2
|
+
import { BaseClient } from './base-client.js';
|
|
3
|
+
/**
|
|
4
|
+
* Internal sub-client handling all comment-domain endpoints.
|
|
5
|
+
*
|
|
6
|
+
* Instantiated by `TodoistApi`; every public comment method on `TodoistApi`
|
|
7
|
+
* delegates here. See `todoist-api.ts` for the user-facing JSDoc.
|
|
8
|
+
*/
|
|
9
|
+
export declare class CommentClient extends BaseClient {
|
|
10
|
+
getComments(args: GetTaskCommentsArgs | GetProjectCommentsArgs): Promise<GetCommentsResponse>;
|
|
11
|
+
getComment(id: string): Promise<Comment>;
|
|
12
|
+
addComment(args: AddCommentArgs, requestId?: string): Promise<Comment>;
|
|
13
|
+
updateComment(id: string, args: UpdateCommentArgs, requestId?: string): Promise<Comment>;
|
|
14
|
+
deleteComment(id: string, requestId?: string): Promise<boolean>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DisableEmailArgs, GetOrCreateEmailArgs, GetOrCreateEmailResponse } from '../types/emails/index.js';
|
|
2
|
+
import { BaseClient } from './base-client.js';
|
|
3
|
+
/**
|
|
4
|
+
* Internal sub-client handling email-forwarding endpoints.
|
|
5
|
+
*
|
|
6
|
+
* Instantiated by `TodoistApi`; every public email-forwarding method on
|
|
7
|
+
* `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
|
|
8
|
+
* JSDoc.
|
|
9
|
+
*/
|
|
10
|
+
export declare class EmailClient extends BaseClient {
|
|
11
|
+
getOrCreateEmailForwarding(args: GetOrCreateEmailArgs, requestId?: string): Promise<GetOrCreateEmailResponse>;
|
|
12
|
+
disableEmailForwarding(args: DisableEmailArgs, requestId?: string): Promise<boolean>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BaseClient } from './base-client.js';
|
|
2
|
+
/**
|
|
3
|
+
* Internal sub-client handling all filter-domain endpoints.
|
|
4
|
+
*
|
|
5
|
+
* Instantiated by `TodoistApi`; every public filter method on `TodoistApi`
|
|
6
|
+
* delegates here. See `todoist-api.ts` for the user-facing JSDoc.
|
|
7
|
+
*/
|
|
8
|
+
export declare class FilterClient extends BaseClient {
|
|
9
|
+
deleteFilter(id: string, requestId?: string): Promise<boolean>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AddFolderArgs, GetFoldersArgs, GetFoldersResponse, UpdateFolderArgs } from '../types/folders/index.js';
|
|
2
|
+
import type { Folder } from '../types/sync/resources/folders.js';
|
|
3
|
+
import { BaseClient } from './base-client.js';
|
|
4
|
+
/**
|
|
5
|
+
* Internal sub-client handling all folder-domain endpoints.
|
|
6
|
+
*
|
|
7
|
+
* Instantiated by `TodoistApi`; every public folder method on `TodoistApi`
|
|
8
|
+
* delegates here. See `todoist-api.ts` for the user-facing JSDoc.
|
|
9
|
+
*/
|
|
10
|
+
export declare class FolderClient extends BaseClient {
|
|
11
|
+
getFolders(args: GetFoldersArgs): Promise<GetFoldersResponse>;
|
|
12
|
+
getFolder(id: string): Promise<Folder>;
|
|
13
|
+
addFolder(args: AddFolderArgs, requestId?: string): Promise<Folder>;
|
|
14
|
+
updateFolder(id: string, args: UpdateFolderArgs, requestId?: string): Promise<Folder>;
|
|
15
|
+
deleteFolder(id: string, requestId?: string): Promise<boolean>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { GetIdMappingsArgs, GetMovedIdsArgs, IdMapping, MovedId } from '../types/id-mappings/index.js';
|
|
2
|
+
import { BaseClient } from './base-client.js';
|
|
3
|
+
/**
|
|
4
|
+
* Internal sub-client handling ID-mapping endpoints.
|
|
5
|
+
*
|
|
6
|
+
* Instantiated by `TodoistApi`; every public id-mapping method on
|
|
7
|
+
* `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
|
|
8
|
+
* JSDoc.
|
|
9
|
+
*/
|
|
10
|
+
export declare class IdMappingClient extends BaseClient {
|
|
11
|
+
getIdMappings(args: GetIdMappingsArgs): Promise<IdMapping[]>;
|
|
12
|
+
getMovedIds(args: GetMovedIdsArgs): Promise<MovedId[]>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { GetProjectActivityStatsArgs, GetWorkspaceInsightsArgs, ProjectActivityStats, ProjectHealth, ProjectHealthContext, ProjectProgress, WorkspaceInsights } from '../types/insights/index.js';
|
|
2
|
+
import { BaseClient } from './base-client.js';
|
|
3
|
+
/**
|
|
4
|
+
* Internal sub-client handling all insights-domain endpoints
|
|
5
|
+
* (project activity stats, health, progress, workspace insights).
|
|
6
|
+
*
|
|
7
|
+
* Instantiated by `TodoistApi`; every public insights method on
|
|
8
|
+
* `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
|
|
9
|
+
* JSDoc.
|
|
10
|
+
*/
|
|
11
|
+
export declare class InsightsClient extends BaseClient {
|
|
12
|
+
getProjectActivityStats(projectId: string, args?: GetProjectActivityStatsArgs): Promise<ProjectActivityStats>;
|
|
13
|
+
getProjectHealth(projectId: string): Promise<ProjectHealth>;
|
|
14
|
+
getProjectHealthContext(projectId: string): Promise<ProjectHealthContext>;
|
|
15
|
+
getProjectProgress(projectId: string): Promise<ProjectProgress>;
|
|
16
|
+
getWorkspaceInsights(workspaceId: string, args?: GetWorkspaceInsightsArgs): Promise<WorkspaceInsights>;
|
|
17
|
+
analyzeProjectHealth(projectId: string, requestId?: string): Promise<ProjectHealth>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AddLabelArgs, GetLabelsArgs, GetLabelsResponse, GetSharedLabelsArgs, GetSharedLabelsResponse, Label, RemoveSharedLabelArgs, RenameSharedLabelArgs, SearchLabelsArgs, UpdateLabelArgs } from '../types/labels/index.js';
|
|
2
|
+
import { BaseClient } from './base-client.js';
|
|
3
|
+
/**
|
|
4
|
+
* Internal sub-client handling all label-domain endpoints.
|
|
5
|
+
*
|
|
6
|
+
* Instantiated by `TodoistApi`; every public label method on `TodoistApi`
|
|
7
|
+
* delegates here. See `todoist-api.ts` for the user-facing JSDoc.
|
|
8
|
+
*/
|
|
9
|
+
export declare class LabelClient extends BaseClient {
|
|
10
|
+
getLabel(id: string): Promise<Label>;
|
|
11
|
+
getLabels(args?: GetLabelsArgs): Promise<GetLabelsResponse>;
|
|
12
|
+
searchLabels(args: SearchLabelsArgs): Promise<GetLabelsResponse>;
|
|
13
|
+
addLabel(args: AddLabelArgs, requestId?: string): Promise<Label>;
|
|
14
|
+
updateLabel(id: string, args: UpdateLabelArgs, requestId?: string): Promise<Label>;
|
|
15
|
+
deleteLabel(id: string, requestId?: string): Promise<boolean>;
|
|
16
|
+
getSharedLabels(args?: GetSharedLabelsArgs): Promise<GetSharedLabelsResponse>;
|
|
17
|
+
renameSharedLabel(args: RenameSharedLabelArgs): Promise<boolean>;
|
|
18
|
+
removeSharedLabel(args: RemoveSharedLabelArgs): Promise<boolean>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ProductivityStats } from '../types/productivity/index.js';
|
|
2
|
+
import { BaseClient } from './base-client.js';
|
|
3
|
+
/**
|
|
4
|
+
* Internal sub-client handling the productivity-stats endpoint.
|
|
5
|
+
*
|
|
6
|
+
* Instantiated by `TodoistApi`; the public `getProductivityStats` method
|
|
7
|
+
* on `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
|
|
8
|
+
* JSDoc.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ProductivityClient extends BaseClient {
|
|
11
|
+
getProductivityStats(): Promise<ProductivityStats>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { AddProjectArgs, GetArchivedProjectsArgs, GetArchivedProjectsCountArgs, GetArchivedProjectsCountResponse, GetArchivedProjectsResponse, GetFullProjectArgs, GetFullProjectResponse, GetProjectCollaboratorsArgs, GetProjectCollaboratorsResponse, GetProjectPermissionsResponse, GetProjectsArgs, GetProjectsResponse, JoinProjectResponse, MoveProjectToPersonalArgs, MoveProjectToWorkspaceArgs, PersonalProject, PersonalProjectCapacity, SearchProjectsArgs, UpdateProjectArgs, WorkspaceProject } from '../types/projects/index.js';
|
|
2
|
+
import { BaseClient } from './base-client.js';
|
|
3
|
+
export declare class ProjectClient extends BaseClient {
|
|
4
|
+
getProject(id: string): Promise<PersonalProject | WorkspaceProject>;
|
|
5
|
+
getProjects(args?: GetProjectsArgs): Promise<GetProjectsResponse>;
|
|
6
|
+
searchProjects(args: SearchProjectsArgs): Promise<GetProjectsResponse>;
|
|
7
|
+
getArchivedProjects(args?: GetArchivedProjectsArgs): Promise<GetArchivedProjectsResponse>;
|
|
8
|
+
addProject(args: AddProjectArgs, requestId?: string): Promise<PersonalProject | WorkspaceProject>;
|
|
9
|
+
updateProject(id: string, args: UpdateProjectArgs, requestId?: string): Promise<PersonalProject | WorkspaceProject>;
|
|
10
|
+
deleteProject(id: string, requestId?: string): Promise<boolean>;
|
|
11
|
+
archiveProject(id: string, requestId?: string): Promise<PersonalProject | WorkspaceProject>;
|
|
12
|
+
unarchiveProject(id: string, requestId?: string): Promise<PersonalProject | WorkspaceProject>;
|
|
13
|
+
moveProjectToWorkspace(args: MoveProjectToWorkspaceArgs, requestId?: string): Promise<PersonalProject | WorkspaceProject>;
|
|
14
|
+
moveProjectToPersonal(args: MoveProjectToPersonalArgs, requestId?: string): Promise<PersonalProject | WorkspaceProject>;
|
|
15
|
+
getArchivedProjectsCount(args?: GetArchivedProjectsCountArgs): Promise<GetArchivedProjectsCountResponse>;
|
|
16
|
+
getProjectPermissions(): Promise<GetProjectPermissionsResponse>;
|
|
17
|
+
getFullProject(id: string, args?: GetFullProjectArgs): Promise<GetFullProjectResponse>;
|
|
18
|
+
joinProject(id: string, requestId?: string): Promise<JoinProjectResponse>;
|
|
19
|
+
getProjectCollaborators(projectId: string, args?: GetProjectCollaboratorsArgs): Promise<GetProjectCollaboratorsResponse>;
|
|
20
|
+
getPersonalProjectCapacity(): Promise<PersonalProjectCapacity>;
|
|
21
|
+
private countActivePersonalProjects;
|
|
22
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Reminder } from '../types/index.js';
|
|
2
|
+
import type { AddLocationReminderArgs, AddReminderArgs, GetLocationRemindersArgs, GetLocationRemindersResponse, GetRemindersArgs, GetRemindersResponse, UpdateLocationReminderArgs, UpdateReminderArgs } from '../types/reminders/index.js';
|
|
3
|
+
import { BaseClient } from './base-client.js';
|
|
4
|
+
/**
|
|
5
|
+
* Internal sub-client handling all reminder-domain endpoints
|
|
6
|
+
* (both time-based and location-based reminders).
|
|
7
|
+
*
|
|
8
|
+
* Instantiated by `TodoistApi`; every public reminder method on
|
|
9
|
+
* `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
|
|
10
|
+
* JSDoc. The time-vs-location 404 translation is preserved here so a
|
|
11
|
+
* caller who used the wrong endpoint gets a TodoistArgumentError
|
|
12
|
+
* pointing at the correct method, rather than a bare 404.
|
|
13
|
+
*/
|
|
14
|
+
export declare class ReminderClient extends BaseClient {
|
|
15
|
+
getReminders(args?: GetRemindersArgs): Promise<GetRemindersResponse>;
|
|
16
|
+
getLocationReminders(args?: GetLocationRemindersArgs): Promise<GetLocationRemindersResponse>;
|
|
17
|
+
getReminder(id: string): Promise<Reminder>;
|
|
18
|
+
getLocationReminder(id: string): Promise<Reminder>;
|
|
19
|
+
addReminder(args: AddReminderArgs, requestId?: string): Promise<Reminder>;
|
|
20
|
+
addLocationReminder(args: AddLocationReminderArgs, requestId?: string): Promise<Reminder>;
|
|
21
|
+
updateReminder(id: string, args: UpdateReminderArgs, requestId?: string): Promise<Reminder>;
|
|
22
|
+
updateLocationReminder(id: string, args: UpdateLocationReminderArgs, requestId?: string): Promise<Reminder>;
|
|
23
|
+
deleteReminder(id: string, requestId?: string): Promise<boolean>;
|
|
24
|
+
deleteLocationReminder(id: string, requestId?: string): Promise<boolean>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AddSectionArgs, GetSectionsArgs, GetSectionsResponse, SearchSectionsArgs, Section, UpdateSectionArgs } from '../types/sections/index.js';
|
|
2
|
+
import { BaseClient } from './base-client.js';
|
|
3
|
+
/**
|
|
4
|
+
* Internal sub-client handling all section-domain endpoints.
|
|
5
|
+
*
|
|
6
|
+
* Instantiated by `TodoistApi`; every public section method on `TodoistApi`
|
|
7
|
+
* delegates here. See `todoist-api.ts` for the user-facing JSDoc.
|
|
8
|
+
*/
|
|
9
|
+
export declare class SectionClient extends BaseClient {
|
|
10
|
+
getSections(args?: GetSectionsArgs): Promise<GetSectionsResponse>;
|
|
11
|
+
searchSections(args: SearchSectionsArgs): Promise<GetSectionsResponse>;
|
|
12
|
+
getSection(id: string): Promise<Section>;
|
|
13
|
+
addSection(args: AddSectionArgs, requestId?: string): Promise<Section>;
|
|
14
|
+
updateSection(id: string, args: UpdateSectionArgs, requestId?: string): Promise<Section>;
|
|
15
|
+
deleteSection(id: string, requestId?: string): Promise<boolean>;
|
|
16
|
+
archiveSection(id: string, requestId?: string): Promise<Section>;
|
|
17
|
+
unarchiveSection(id: string, requestId?: string): Promise<Section>;
|
|
18
|
+
}
|