@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,12 @@
|
|
|
1
|
+
import type { CustomFetch, HttpResponse, RetryConfig } from '../types/http.js';
|
|
2
|
+
/**
|
|
3
|
+
* Performs a fetch request with retry logic and timeout support
|
|
4
|
+
*/
|
|
5
|
+
export declare function fetchWithRetry<T = unknown>(args: {
|
|
6
|
+
url: string;
|
|
7
|
+
options?: RequestInit & {
|
|
8
|
+
timeout?: number;
|
|
9
|
+
};
|
|
10
|
+
retryConfig?: Partial<RetryConfig>;
|
|
11
|
+
customFetch?: CustomFetch;
|
|
12
|
+
}): Promise<HttpResponse<T>>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { CustomFetch, CustomHeaders, HttpMethod, HttpResponse } from '../types/http.js';
|
|
2
|
+
type RequestArgs = {
|
|
3
|
+
httpMethod: HttpMethod;
|
|
4
|
+
baseUri: string;
|
|
5
|
+
relativePath: string;
|
|
6
|
+
apiToken?: string;
|
|
7
|
+
payload?: Record<string, unknown>;
|
|
8
|
+
requestId?: string;
|
|
9
|
+
hasSyncCommands?: boolean;
|
|
10
|
+
customHeaders?: CustomHeaders;
|
|
11
|
+
customFetch?: CustomFetch;
|
|
12
|
+
/** Top-level response fields whose map keys are identifiers, left out of camel-casing. */
|
|
13
|
+
opaqueKeyMaps?: ReadonlySet<string>;
|
|
14
|
+
};
|
|
15
|
+
export declare function paramsSerializer(params: Record<string, unknown>): string;
|
|
16
|
+
/**
|
|
17
|
+
* Normalises anything thrown while making an API request into the error a
|
|
18
|
+
* caller should see: a `TodoistRequestError` (carrying the HTTP status and
|
|
19
|
+
* response body when there is one) reported against `originalStack`, or a
|
|
20
|
+
* generic `Error` when the thrown value isn't an `Error` at all.
|
|
21
|
+
*/
|
|
22
|
+
export declare function toTodoistRequestError(error: unknown, originalStack?: Error): Error;
|
|
23
|
+
export declare function isSuccess(response: HttpResponse): boolean;
|
|
24
|
+
export declare function request<T>(args: RequestArgs): Promise<HttpResponse<T>>;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { Dispatcher } from 'undici';
|
|
2
|
+
type UndiciFetch = typeof import('undici').fetch;
|
|
3
|
+
/**
|
|
4
|
+
* A dispatcher and the `fetch` that must be used with it. `fetch` is undici's
|
|
5
|
+
* own `fetch` on the full-undici Node path, or `undefined` (meaning: use the
|
|
6
|
+
* global `fetch`) on the Bun path. The two are cached together so callers can
|
|
7
|
+
* never observe a dispatcher paired with a mismatched `fetch` — see
|
|
8
|
+
* {@link getDefaultFetch} for why the pairing matters.
|
|
9
|
+
*/
|
|
10
|
+
export type DefaultTransport = {
|
|
11
|
+
dispatcher: Dispatcher;
|
|
12
|
+
fetch: UndiciFetch | undefined;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The default dispatcher and its paired `fetch`, as a single value so the two
|
|
16
|
+
* are always read consistently. Resolves to `undefined` outside Node (browser/
|
|
17
|
+
* edge), where callers use the global `fetch` with no dispatcher.
|
|
18
|
+
*
|
|
19
|
+
* Use this when supplying a `customFetch` that should still honour the proxy
|
|
20
|
+
* environment variables (`HTTP_PROXY`, `HTTPS_PROXY`, `NO_PROXY`) and decode
|
|
21
|
+
* compressed responses the way the SDK does by default.
|
|
22
|
+
*
|
|
23
|
+
* Both halves must be used together. `dispatcher` decompresses the response
|
|
24
|
+
* body itself, so a `fetch` from a different undici build will try to decode
|
|
25
|
+
* it a second time and the request fails mid-stream with `terminated`. A
|
|
26
|
+
* `fetch` of `undefined` means the runtime's global `fetch` is the correct
|
|
27
|
+
* partner for this dispatcher.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const transport = await getDefaultTransport()
|
|
32
|
+
* const fetchImpl = transport?.fetch ?? fetch
|
|
33
|
+
* const response = await fetchImpl(url, { ...options, dispatcher: transport?.dispatcher })
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function getDefaultTransport(): Promise<DefaultTransport | undefined>;
|
|
37
|
+
/**
|
|
38
|
+
* The default dispatcher on its own.
|
|
39
|
+
*
|
|
40
|
+
* @deprecated Use {@link getDefaultTransport} instead, which returns this
|
|
41
|
+
* dispatcher together with the `fetch` it must be used with. Attaching this
|
|
42
|
+
* dispatcher to the runtime's global `fetch` decodes compressed responses
|
|
43
|
+
* twice on Node 26 and the request fails with `terminated`.
|
|
44
|
+
*/
|
|
45
|
+
export declare function getDefaultDispatcher(): Promise<Dispatcher | undefined>;
|
|
46
|
+
/**
|
|
47
|
+
* The `fetch` implementation that must be used with the default dispatcher.
|
|
48
|
+
* Returns undici's own `fetch` on the full-undici Node path, or `undefined`
|
|
49
|
+
* (meaning: use the global `fetch`) in the browser/edge/Bun paths.
|
|
50
|
+
*
|
|
51
|
+
* Node's global `fetch` is backed by whatever undici version ships inside that
|
|
52
|
+
* Node release (6.x on Node 22 … 8.x on Node 26). Our dispatcher — and its
|
|
53
|
+
* `decompress` interceptor — comes from the npm `undici` package, which is a
|
|
54
|
+
* different version. Handing an npm-undici dispatcher to a mismatched built-in
|
|
55
|
+
* client makes gzip responses fail mid-stream with `terminated`. Sourcing
|
|
56
|
+
* `fetch` from the same npm `undici` keeps the whole request path on one
|
|
57
|
+
* version and removes the split.
|
|
58
|
+
*
|
|
59
|
+
* Only meaningful after {@link getDefaultTransport} has resolved, which is the
|
|
60
|
+
* one place that populates it.
|
|
61
|
+
*/
|
|
62
|
+
export declare function getDefaultFetch(): UndiciFetch | undefined;
|
|
63
|
+
export declare function resetDefaultDispatcherForTests(): Promise<void>;
|
|
64
|
+
export declare function suppressExperimentalWarningsSync<T>(fn: () => T): T;
|
|
65
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { CustomFetch, CustomHeaders } from '../types/http.js';
|
|
2
|
+
import { type SyncRequest, type SyncResponse } from '../types/sync/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Shared context needed to issue Sync API requests.
|
|
5
|
+
*
|
|
6
|
+
* Constructed by {@link TodoistApi} and each {@link BaseClient} subclass so
|
|
7
|
+
* that sub-clients can delegate to {@link performSyncRequest} without
|
|
8
|
+
* rebuilding the HTTP identity on every call.
|
|
9
|
+
*/
|
|
10
|
+
export type SyncRequestContext = {
|
|
11
|
+
authToken: string;
|
|
12
|
+
syncApiBase: string;
|
|
13
|
+
customFetch?: CustomFetch;
|
|
14
|
+
customHeaders?: CustomHeaders;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Makes a request to the Sync API and handles error checking.
|
|
18
|
+
*
|
|
19
|
+
* @param ctx - HTTP identity (auth token, sync API base URI, optional custom fetch and headers).
|
|
20
|
+
* @param syncRequest - The sync request payload.
|
|
21
|
+
* @param options - Optional request identifier and commands flag.
|
|
22
|
+
* @returns The sync response data, with `syncStatus` keyed by command `uuid` and
|
|
23
|
+
* `tempIdMapping` keyed by command `tempId`.
|
|
24
|
+
* @throws TodoistSyncError if any command failed. Commands are applied
|
|
25
|
+
* independently, so its `syncStatus` and `tempIdMapping` report the ones that
|
|
26
|
+
* were applied regardless.
|
|
27
|
+
*/
|
|
28
|
+
export declare function performSyncRequest(ctx: SyncRequestContext, syncRequest: SyncRequest, options?: {
|
|
29
|
+
requestId?: string;
|
|
30
|
+
hasSyncCommands?: boolean;
|
|
31
|
+
}): Promise<SyncResponse>;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { ActivityEvent, ActivityObjectEventType } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Common arguments for retrieving activity logs (excluding filter-type params).
|
|
4
|
+
*/
|
|
5
|
+
type GetActivityLogsArgsCommon = {
|
|
6
|
+
/**
|
|
7
|
+
* Filter by the ID of a specific object.
|
|
8
|
+
*/
|
|
9
|
+
objectId?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Filter events by parent project ID.
|
|
12
|
+
*/
|
|
13
|
+
parentProjectId?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Filter events by parent task ID.
|
|
16
|
+
*/
|
|
17
|
+
parentItemId?: string;
|
|
18
|
+
/**
|
|
19
|
+
* When true, includes the parent object data in the response.
|
|
20
|
+
*/
|
|
21
|
+
includeParentObject?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* When true, includes child object data in the response.
|
|
24
|
+
*/
|
|
25
|
+
includeChildObjects?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Filter by the user ID who initiated the event.
|
|
28
|
+
*/
|
|
29
|
+
initiatorId?: string;
|
|
30
|
+
/**
|
|
31
|
+
* When true, filters for events with no initiator (system-generated events).
|
|
32
|
+
* When false, filters for events with an initiator.
|
|
33
|
+
* When null or undefined, no filtering on initiator is applied.
|
|
34
|
+
*/
|
|
35
|
+
initiatorIdNull?: boolean | null;
|
|
36
|
+
/**
|
|
37
|
+
* When true, ensures the last state of objects is included in the response.
|
|
38
|
+
*/
|
|
39
|
+
ensureLastState?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* When true, includes comment annotations in the response.
|
|
42
|
+
*/
|
|
43
|
+
annotateNotes?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* When true, includes parent object annotations in the response.
|
|
46
|
+
*/
|
|
47
|
+
annotateParents?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Pagination cursor for retrieving the next page of results.
|
|
50
|
+
*/
|
|
51
|
+
cursor?: string | null;
|
|
52
|
+
/**
|
|
53
|
+
* Maximum number of results to return per page.
|
|
54
|
+
*/
|
|
55
|
+
limit?: number;
|
|
56
|
+
/**
|
|
57
|
+
* Start date for filtering events (inclusive). Replaces deprecated `since`.
|
|
58
|
+
* Accepts a Date object or YYYY-MM-DD string.
|
|
59
|
+
*/
|
|
60
|
+
dateFrom?: Date | string;
|
|
61
|
+
/**
|
|
62
|
+
* End date for filtering events (inclusive). Replaces deprecated `until`.
|
|
63
|
+
* Accepts a Date object or YYYY-MM-DD string.
|
|
64
|
+
*/
|
|
65
|
+
dateTo?: Date | string;
|
|
66
|
+
};
|
|
67
|
+
export type GetActivityLogsArgs = GetActivityLogsArgsCommon & {
|
|
68
|
+
objectEventTypes?: ActivityObjectEventType | ActivityObjectEventType[];
|
|
69
|
+
/** @removed Use `objectEventTypes` instead. */
|
|
70
|
+
objectType?: never;
|
|
71
|
+
/** @removed Use `objectEventTypes` instead. */
|
|
72
|
+
eventType?: never;
|
|
73
|
+
/** @removed Use `dateFrom` instead. */
|
|
74
|
+
since?: never;
|
|
75
|
+
/** @removed Use `dateTo` instead. */
|
|
76
|
+
until?: never;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Response from retrieving activity logs.
|
|
80
|
+
*/
|
|
81
|
+
export type GetActivityLogsResponse = {
|
|
82
|
+
results: ActivityEvent[];
|
|
83
|
+
nextCursor: string | null;
|
|
84
|
+
};
|
|
85
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Known activity object types, using modern names (`task`, `comment`) rather
|
|
4
|
+
* than legacy API names (`item`, `note`).
|
|
5
|
+
*/
|
|
6
|
+
export declare const ACTIVITY_OBJECT_TYPES: readonly ["task", "comment", "project"];
|
|
7
|
+
/**
|
|
8
|
+
* Known activity event types.
|
|
9
|
+
*/
|
|
10
|
+
export declare const ACTIVITY_EVENT_TYPES: readonly ["added", "updated", "deleted", "completed", "uncompleted", "archived", "unarchived", "shared", "left", "moved"];
|
|
11
|
+
/**
|
|
12
|
+
* Type hints for known object types. Accepts any string for forward compatibility.
|
|
13
|
+
*/
|
|
14
|
+
export type ActivityObjectType = (typeof ACTIVITY_OBJECT_TYPES)[number] | (string & Record<string, never>);
|
|
15
|
+
/**
|
|
16
|
+
* Type hints for known event types. Accepts any string for forward compatibility.
|
|
17
|
+
*/
|
|
18
|
+
export type ActivityEventType = (typeof ACTIVITY_EVENT_TYPES)[number] | (string & Record<string, never>);
|
|
19
|
+
/**
|
|
20
|
+
* Combined object:event filter string for the `objectEventTypes` parameter of `getActivityLogs`.
|
|
21
|
+
*
|
|
22
|
+
* Uses modern object type names (`task`, `comment`) rather than legacy API names (`item`, `note`).
|
|
23
|
+
* Either part may be omitted:
|
|
24
|
+
* - `'task:added'` — task additions only
|
|
25
|
+
* - `'task:'` — all events for tasks
|
|
26
|
+
* - `':deleted'` — all deleted events across all object types
|
|
27
|
+
*
|
|
28
|
+
* The final `string & Record<string, never>` member allows any arbitrary string
|
|
29
|
+
* to be passed for forward compatibility, while still providing autocomplete for
|
|
30
|
+
* the known combinations above.
|
|
31
|
+
*/
|
|
32
|
+
export type ActivityObjectEventType = `${ActivityObjectType}:${ActivityEventType}` | `${ActivityObjectType}:` | `:${ActivityEventType}` | (string & Record<string, never>);
|
|
33
|
+
/**
|
|
34
|
+
* Flexible object containing event-specific data.
|
|
35
|
+
* Uses z.record to accept any properties for forward compatibility.
|
|
36
|
+
*/
|
|
37
|
+
export declare const ActivityEventExtraDataSchema: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
38
|
+
export type ActivityEventExtraData = z.infer<typeof ActivityEventExtraDataSchema>;
|
|
39
|
+
/**
|
|
40
|
+
* Activity log event schema. Accepts unknown fields for forward compatibility.
|
|
41
|
+
*/
|
|
42
|
+
export declare const ActivityEventSchema: z.ZodObject<{
|
|
43
|
+
objectType: z.ZodString;
|
|
44
|
+
objectId: z.ZodString;
|
|
45
|
+
eventType: z.ZodString;
|
|
46
|
+
eventDate: z.ZodCoercedDate<unknown>;
|
|
47
|
+
id: z.ZodNullable<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>>;
|
|
48
|
+
parentProjectId: z.ZodNullable<z.ZodString>;
|
|
49
|
+
parentItemId: z.ZodNullable<z.ZodString>;
|
|
50
|
+
initiatorId: z.ZodNullable<z.ZodString>;
|
|
51
|
+
extraData: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
52
|
+
}, z.core.$catchall<z.ZodAny>>;
|
|
53
|
+
/**
|
|
54
|
+
* Represents an activity log event in Todoist.
|
|
55
|
+
*/
|
|
56
|
+
export type ActivityEvent = z.infer<typeof ActivityEventSchema>;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { Permission } from '../../authentication.js';
|
|
2
|
+
import type { AppIconSize } from '../../consts/endpoints.js';
|
|
3
|
+
import type { AppClientType, InstallationType, WebhookEvent, WebhookVersion } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Arguments for creating a new developer application.
|
|
6
|
+
*/
|
|
7
|
+
export type AddAppArgs = {
|
|
8
|
+
/** Display name of the application. */
|
|
9
|
+
displayName: string;
|
|
10
|
+
/** The application's service URL. */
|
|
11
|
+
serviceUrl: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Arguments for updating a developer application.
|
|
15
|
+
* All fields are optional — only provided fields are updated.
|
|
16
|
+
*
|
|
17
|
+
* Pass `appTokenScopes` as an array (e.g. `['data:read', 'task:add']`);
|
|
18
|
+
* the SDK serializes it to the comma-separated string the backend expects.
|
|
19
|
+
*/
|
|
20
|
+
export type UpdateAppArgs = {
|
|
21
|
+
/** Updated display name. */
|
|
22
|
+
displayName?: string;
|
|
23
|
+
/** Updated OAuth redirect URI. Pass `null` to clear. */
|
|
24
|
+
oauthRedirectUri?: string | null;
|
|
25
|
+
/** Updated service URL. */
|
|
26
|
+
serviceUrl?: string;
|
|
27
|
+
/** Updated app description. */
|
|
28
|
+
description?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Updated list of scopes the app may request. Pass `null` to clear.
|
|
31
|
+
*
|
|
32
|
+
* Typed as `Permission | (string & {})` so known scopes get autocomplete
|
|
33
|
+
* while still permitting plain strings — needed so a fetched
|
|
34
|
+
* `App['appTokenScopes']` (typed `string[] | null`) can be passed back
|
|
35
|
+
* to `updateApp()` without casts.
|
|
36
|
+
*/
|
|
37
|
+
appTokenScopes?: readonly (Permission | (string & {}))[] | null;
|
|
38
|
+
/**
|
|
39
|
+
* Updated OAuth client type. Set to `'public'` for apps that cannot keep a
|
|
40
|
+
* secret (native apps, browser extensions, CLIs), so they exchange
|
|
41
|
+
* authorization codes with PKCE alone. The client secret is kept, so
|
|
42
|
+
* switching back to `'confidential'` needs no new one.
|
|
43
|
+
*
|
|
44
|
+
* Dynamically registered clients cannot change it: the API rejects the
|
|
45
|
+
* update with `BAD_REQUEST`.
|
|
46
|
+
*/
|
|
47
|
+
clientType?: AppClientType;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Arguments for uploading an app icon.
|
|
51
|
+
*/
|
|
52
|
+
export type UploadAppIconArgs = {
|
|
53
|
+
/** The application ID. */
|
|
54
|
+
appId: string;
|
|
55
|
+
/** The icon file to upload (Buffer, Stream, or file path). */
|
|
56
|
+
file: Buffer | NodeJS.ReadableStream | string | Blob;
|
|
57
|
+
/** The file name (required for Buffer/Stream uploads). */
|
|
58
|
+
fileName?: string;
|
|
59
|
+
/** Icon size variant. Defaults to `'medium'`. */
|
|
60
|
+
size?: AppIconSize;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Arguments for configuring (creating or updating) an app webhook.
|
|
64
|
+
*/
|
|
65
|
+
export type UpdateAppWebhookArgs = {
|
|
66
|
+
/** The application ID. */
|
|
67
|
+
appId: string;
|
|
68
|
+
/** The URL the webhook will POST events to. */
|
|
69
|
+
callbackUrl: string;
|
|
70
|
+
/** Events the webhook should receive. Must be unique. */
|
|
71
|
+
events: readonly WebhookEvent[];
|
|
72
|
+
/** Webhook payload version. Defaults to the backend's latest supported version. */
|
|
73
|
+
version?: WebhookVersion;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Arguments for installing a developer application via its distribution token.
|
|
77
|
+
*/
|
|
78
|
+
export type InstallAppArgs = {
|
|
79
|
+
/** The distribution token for the app being installed. */
|
|
80
|
+
distributionToken: string;
|
|
81
|
+
/** Type of installation to create. */
|
|
82
|
+
installationType: InstallationType;
|
|
83
|
+
/** Whether the requesting client has validated the app's requested scopes with the user. */
|
|
84
|
+
appTokenScopesValidated?: boolean;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Arguments for updating an app installation.
|
|
88
|
+
*/
|
|
89
|
+
export type UpdateAppInstallationArgs = {
|
|
90
|
+
/** Updated validated-scopes flag. */
|
|
91
|
+
appTokenScopesValidated?: boolean;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Arguments for revoking a user's authorization of a third-party app.
|
|
95
|
+
*/
|
|
96
|
+
export type RevokeUserAuthorizationArgs = {
|
|
97
|
+
/** The ID of the access token to revoke. */
|
|
98
|
+
accessTokenId: string;
|
|
99
|
+
};
|