@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,92 @@
|
|
|
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_COMMENTS } from '../consts/endpoints.js';
|
|
13
|
+
import { isSuccess, request } from '../transport/http-client.js';
|
|
14
|
+
import { generatePath } from '../utils/request-helpers.js';
|
|
15
|
+
import { IdSchema, validateComment, validateCommentArray } from '../utils/validators.js';
|
|
16
|
+
import { BaseClient } from './base-client.js';
|
|
17
|
+
/**
|
|
18
|
+
* Internal sub-client handling all comment-domain endpoints.
|
|
19
|
+
*
|
|
20
|
+
* Instantiated by `TodoistApi`; every public comment method on `TodoistApi`
|
|
21
|
+
* delegates here. See `todoist-api.ts` for the user-facing JSDoc.
|
|
22
|
+
*/
|
|
23
|
+
export class CommentClient extends BaseClient {
|
|
24
|
+
async getComments(args) {
|
|
25
|
+
const { data: { results, nextCursor }, } = await request({
|
|
26
|
+
httpMethod: 'GET',
|
|
27
|
+
baseUri: this.syncApiBase,
|
|
28
|
+
relativePath: ENDPOINT_REST_COMMENTS,
|
|
29
|
+
apiToken: this.authToken,
|
|
30
|
+
customFetch: this.customFetch,
|
|
31
|
+
customHeaders: this.customHeaders,
|
|
32
|
+
payload: args,
|
|
33
|
+
});
|
|
34
|
+
return {
|
|
35
|
+
results: validateCommentArray(results),
|
|
36
|
+
nextCursor,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
async getComment(id) {
|
|
40
|
+
IdSchema.parse(id);
|
|
41
|
+
const response = await request({
|
|
42
|
+
httpMethod: 'GET',
|
|
43
|
+
baseUri: this.syncApiBase,
|
|
44
|
+
relativePath: generatePath(ENDPOINT_REST_COMMENTS, id),
|
|
45
|
+
apiToken: this.authToken,
|
|
46
|
+
customFetch: this.customFetch,
|
|
47
|
+
customHeaders: this.customHeaders,
|
|
48
|
+
});
|
|
49
|
+
return validateComment(response.data);
|
|
50
|
+
}
|
|
51
|
+
async addComment(args, requestId) {
|
|
52
|
+
const { uidsToNotify } = args, rest = __rest(args, ["uidsToNotify"]);
|
|
53
|
+
const response = await request({
|
|
54
|
+
httpMethod: 'POST',
|
|
55
|
+
baseUri: this.syncApiBase,
|
|
56
|
+
relativePath: ENDPOINT_REST_COMMENTS,
|
|
57
|
+
apiToken: this.authToken,
|
|
58
|
+
customFetch: this.customFetch,
|
|
59
|
+
customHeaders: this.customHeaders,
|
|
60
|
+
payload: Object.assign(Object.assign({}, rest), ((uidsToNotify === null || uidsToNotify === void 0 ? void 0 : uidsToNotify.length) ? { uidsToNotify } : {})),
|
|
61
|
+
requestId: requestId,
|
|
62
|
+
});
|
|
63
|
+
return validateComment(response.data);
|
|
64
|
+
}
|
|
65
|
+
async updateComment(id, args, requestId) {
|
|
66
|
+
IdSchema.parse(id);
|
|
67
|
+
const response = await request({
|
|
68
|
+
httpMethod: 'POST',
|
|
69
|
+
baseUri: this.syncApiBase,
|
|
70
|
+
relativePath: generatePath(ENDPOINT_REST_COMMENTS, id),
|
|
71
|
+
apiToken: this.authToken,
|
|
72
|
+
customFetch: this.customFetch,
|
|
73
|
+
customHeaders: this.customHeaders,
|
|
74
|
+
payload: args,
|
|
75
|
+
requestId: requestId,
|
|
76
|
+
});
|
|
77
|
+
return validateComment(response.data);
|
|
78
|
+
}
|
|
79
|
+
async deleteComment(id, requestId) {
|
|
80
|
+
IdSchema.parse(id);
|
|
81
|
+
const response = await request({
|
|
82
|
+
httpMethod: 'DELETE',
|
|
83
|
+
baseUri: this.syncApiBase,
|
|
84
|
+
relativePath: generatePath(ENDPOINT_REST_COMMENTS, id),
|
|
85
|
+
apiToken: this.authToken,
|
|
86
|
+
customFetch: this.customFetch,
|
|
87
|
+
customHeaders: this.customHeaders,
|
|
88
|
+
requestId: requestId,
|
|
89
|
+
});
|
|
90
|
+
return isSuccess(response);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ENDPOINT_REST_EMAILS } from '../consts/endpoints.js';
|
|
2
|
+
import { isSuccess, request } from '../transport/http-client.js';
|
|
3
|
+
import { BaseClient } from './base-client.js';
|
|
4
|
+
/**
|
|
5
|
+
* Internal sub-client handling email-forwarding endpoints.
|
|
6
|
+
*
|
|
7
|
+
* Instantiated by `TodoistApi`; every public email-forwarding method on
|
|
8
|
+
* `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
|
|
9
|
+
* JSDoc.
|
|
10
|
+
*/
|
|
11
|
+
export class EmailClient extends BaseClient {
|
|
12
|
+
async getOrCreateEmailForwarding(args, requestId) {
|
|
13
|
+
const { data } = await request({
|
|
14
|
+
httpMethod: 'PUT',
|
|
15
|
+
baseUri: this.syncApiBase,
|
|
16
|
+
relativePath: ENDPOINT_REST_EMAILS,
|
|
17
|
+
apiToken: this.authToken,
|
|
18
|
+
customFetch: this.customFetch,
|
|
19
|
+
customHeaders: this.customHeaders,
|
|
20
|
+
payload: args,
|
|
21
|
+
requestId: requestId,
|
|
22
|
+
});
|
|
23
|
+
return data;
|
|
24
|
+
}
|
|
25
|
+
async disableEmailForwarding(args, requestId) {
|
|
26
|
+
const queryParams = new URLSearchParams({
|
|
27
|
+
obj_type: args.objType,
|
|
28
|
+
obj_id: args.objId,
|
|
29
|
+
});
|
|
30
|
+
const response = await request({
|
|
31
|
+
httpMethod: 'DELETE',
|
|
32
|
+
baseUri: this.syncApiBase,
|
|
33
|
+
relativePath: `${ENDPOINT_REST_EMAILS}?${queryParams.toString()}`,
|
|
34
|
+
apiToken: this.authToken,
|
|
35
|
+
customFetch: this.customFetch,
|
|
36
|
+
customHeaders: this.customHeaders,
|
|
37
|
+
requestId: requestId,
|
|
38
|
+
});
|
|
39
|
+
return isSuccess(response);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ENDPOINT_REST_FILTERS } from '../consts/endpoints.js';
|
|
2
|
+
import { isSuccess, request } from '../transport/http-client.js';
|
|
3
|
+
import { generatePath } from '../utils/request-helpers.js';
|
|
4
|
+
import { IdSchema } from '../utils/validators.js';
|
|
5
|
+
import { BaseClient } from './base-client.js';
|
|
6
|
+
/**
|
|
7
|
+
* Internal sub-client handling all filter-domain endpoints.
|
|
8
|
+
*
|
|
9
|
+
* Instantiated by `TodoistApi`; every public filter method on `TodoistApi`
|
|
10
|
+
* delegates here. See `todoist-api.ts` for the user-facing JSDoc.
|
|
11
|
+
*/
|
|
12
|
+
export class FilterClient extends BaseClient {
|
|
13
|
+
async deleteFilter(id, requestId) {
|
|
14
|
+
IdSchema.parse(id);
|
|
15
|
+
const response = await request({
|
|
16
|
+
httpMethod: 'DELETE',
|
|
17
|
+
baseUri: this.syncApiBase,
|
|
18
|
+
relativePath: generatePath(ENDPOINT_REST_FILTERS, id),
|
|
19
|
+
apiToken: this.authToken,
|
|
20
|
+
customFetch: this.customFetch,
|
|
21
|
+
customHeaders: this.customHeaders,
|
|
22
|
+
requestId: requestId,
|
|
23
|
+
});
|
|
24
|
+
return isSuccess(response);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { ENDPOINT_REST_FOLDERS } from '../consts/endpoints.js';
|
|
2
|
+
import { isSuccess, request } from '../transport/http-client.js';
|
|
3
|
+
import { generatePath } from '../utils/request-helpers.js';
|
|
4
|
+
import { IdSchema, validateFolder, validateFolderArray } from '../utils/validators.js';
|
|
5
|
+
import { BaseClient } from './base-client.js';
|
|
6
|
+
/**
|
|
7
|
+
* Internal sub-client handling all folder-domain endpoints.
|
|
8
|
+
*
|
|
9
|
+
* Instantiated by `TodoistApi`; every public folder method on `TodoistApi`
|
|
10
|
+
* delegates here. See `todoist-api.ts` for the user-facing JSDoc.
|
|
11
|
+
*/
|
|
12
|
+
export class FolderClient extends BaseClient {
|
|
13
|
+
async getFolders(args) {
|
|
14
|
+
const { data: { results, nextCursor }, } = await request({
|
|
15
|
+
httpMethod: 'GET',
|
|
16
|
+
baseUri: this.syncApiBase,
|
|
17
|
+
relativePath: ENDPOINT_REST_FOLDERS,
|
|
18
|
+
apiToken: this.authToken,
|
|
19
|
+
customFetch: this.customFetch,
|
|
20
|
+
customHeaders: this.customHeaders,
|
|
21
|
+
payload: args,
|
|
22
|
+
});
|
|
23
|
+
return {
|
|
24
|
+
results: validateFolderArray(results),
|
|
25
|
+
nextCursor,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
async getFolder(id) {
|
|
29
|
+
IdSchema.parse(id);
|
|
30
|
+
const response = await request({
|
|
31
|
+
httpMethod: 'GET',
|
|
32
|
+
baseUri: this.syncApiBase,
|
|
33
|
+
relativePath: generatePath(ENDPOINT_REST_FOLDERS, id),
|
|
34
|
+
apiToken: this.authToken,
|
|
35
|
+
customFetch: this.customFetch,
|
|
36
|
+
customHeaders: this.customHeaders,
|
|
37
|
+
});
|
|
38
|
+
return validateFolder(response.data);
|
|
39
|
+
}
|
|
40
|
+
async addFolder(args, requestId) {
|
|
41
|
+
const response = await request({
|
|
42
|
+
httpMethod: 'POST',
|
|
43
|
+
baseUri: this.syncApiBase,
|
|
44
|
+
relativePath: ENDPOINT_REST_FOLDERS,
|
|
45
|
+
apiToken: this.authToken,
|
|
46
|
+
customFetch: this.customFetch,
|
|
47
|
+
customHeaders: this.customHeaders,
|
|
48
|
+
payload: args,
|
|
49
|
+
requestId: requestId,
|
|
50
|
+
});
|
|
51
|
+
return validateFolder(response.data);
|
|
52
|
+
}
|
|
53
|
+
async updateFolder(id, args, requestId) {
|
|
54
|
+
IdSchema.parse(id);
|
|
55
|
+
const response = await request({
|
|
56
|
+
httpMethod: 'POST',
|
|
57
|
+
baseUri: this.syncApiBase,
|
|
58
|
+
relativePath: generatePath(ENDPOINT_REST_FOLDERS, id),
|
|
59
|
+
apiToken: this.authToken,
|
|
60
|
+
customFetch: this.customFetch,
|
|
61
|
+
customHeaders: this.customHeaders,
|
|
62
|
+
payload: args,
|
|
63
|
+
requestId: requestId,
|
|
64
|
+
});
|
|
65
|
+
return validateFolder(response.data);
|
|
66
|
+
}
|
|
67
|
+
async deleteFolder(id, requestId) {
|
|
68
|
+
IdSchema.parse(id);
|
|
69
|
+
const response = await request({
|
|
70
|
+
httpMethod: 'DELETE',
|
|
71
|
+
baseUri: this.syncApiBase,
|
|
72
|
+
relativePath: generatePath(ENDPOINT_REST_FOLDERS, id),
|
|
73
|
+
apiToken: this.authToken,
|
|
74
|
+
customFetch: this.customFetch,
|
|
75
|
+
customHeaders: this.customHeaders,
|
|
76
|
+
requestId: requestId,
|
|
77
|
+
});
|
|
78
|
+
return isSuccess(response);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ENDPOINT_REST_ID_MAPPINGS, ENDPOINT_REST_MOVED_IDS } from '../consts/endpoints.js';
|
|
2
|
+
import { request } from '../transport/http-client.js';
|
|
3
|
+
import { generatePath } from '../utils/request-helpers.js';
|
|
4
|
+
import { validateIdMappingArray, validateMovedIdArray } from '../utils/validators.js';
|
|
5
|
+
import { BaseClient } from './base-client.js';
|
|
6
|
+
/**
|
|
7
|
+
* Internal sub-client handling ID-mapping endpoints.
|
|
8
|
+
*
|
|
9
|
+
* Instantiated by `TodoistApi`; every public id-mapping method on
|
|
10
|
+
* `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
|
|
11
|
+
* JSDoc.
|
|
12
|
+
*/
|
|
13
|
+
export class IdMappingClient extends BaseClient {
|
|
14
|
+
async getIdMappings(args) {
|
|
15
|
+
const response = await request({
|
|
16
|
+
httpMethod: 'GET',
|
|
17
|
+
baseUri: this.syncApiBase,
|
|
18
|
+
relativePath: generatePath(ENDPOINT_REST_ID_MAPPINGS, args.objName, args.objIds.join(',')),
|
|
19
|
+
apiToken: this.authToken,
|
|
20
|
+
customFetch: this.customFetch,
|
|
21
|
+
customHeaders: this.customHeaders,
|
|
22
|
+
});
|
|
23
|
+
return validateIdMappingArray(response.data);
|
|
24
|
+
}
|
|
25
|
+
async getMovedIds(args) {
|
|
26
|
+
const response = await request({
|
|
27
|
+
httpMethod: 'GET',
|
|
28
|
+
baseUri: this.syncApiBase,
|
|
29
|
+
relativePath: generatePath(ENDPOINT_REST_MOVED_IDS, args.objName),
|
|
30
|
+
apiToken: this.authToken,
|
|
31
|
+
customFetch: this.customFetch,
|
|
32
|
+
customHeaders: this.customHeaders,
|
|
33
|
+
payload: args.oldIds ? { oldIds: args.oldIds.join(',') } : undefined,
|
|
34
|
+
});
|
|
35
|
+
return validateMovedIdArray(response.data);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { getProjectInsightsActivityStatsEndpoint, getProjectInsightsHealthAnalyzeEndpoint, getProjectInsightsHealthContextEndpoint, getProjectInsightsHealthEndpoint, getProjectInsightsProgressEndpoint, getWorkspaceInsightsEndpoint, } from '../consts/endpoints.js';
|
|
2
|
+
import { request } from '../transport/http-client.js';
|
|
3
|
+
import { IdSchema, validateProjectActivityStats, validateProjectHealth, validateProjectHealthContext, validateProjectProgress, validateWorkspaceInsights, } from '../utils/validators.js';
|
|
4
|
+
import { BaseClient } from './base-client.js';
|
|
5
|
+
/**
|
|
6
|
+
* Internal sub-client handling all insights-domain endpoints
|
|
7
|
+
* (project activity stats, health, progress, workspace insights).
|
|
8
|
+
*
|
|
9
|
+
* Instantiated by `TodoistApi`; every public insights method on
|
|
10
|
+
* `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
|
|
11
|
+
* JSDoc.
|
|
12
|
+
*/
|
|
13
|
+
export class InsightsClient extends BaseClient {
|
|
14
|
+
async getProjectActivityStats(projectId, args = {}) {
|
|
15
|
+
IdSchema.parse(projectId);
|
|
16
|
+
const response = await request({
|
|
17
|
+
httpMethod: 'GET',
|
|
18
|
+
baseUri: this.syncApiBase,
|
|
19
|
+
relativePath: getProjectInsightsActivityStatsEndpoint(projectId),
|
|
20
|
+
apiToken: this.authToken,
|
|
21
|
+
customFetch: this.customFetch,
|
|
22
|
+
customHeaders: this.customHeaders,
|
|
23
|
+
payload: Object.assign({ objectType: 'ITEM', eventType: 'COMPLETED' }, args),
|
|
24
|
+
});
|
|
25
|
+
return validateProjectActivityStats(response.data);
|
|
26
|
+
}
|
|
27
|
+
async getProjectHealth(projectId) {
|
|
28
|
+
IdSchema.parse(projectId);
|
|
29
|
+
const response = await request({
|
|
30
|
+
httpMethod: 'GET',
|
|
31
|
+
baseUri: this.syncApiBase,
|
|
32
|
+
relativePath: getProjectInsightsHealthEndpoint(projectId),
|
|
33
|
+
apiToken: this.authToken,
|
|
34
|
+
customFetch: this.customFetch,
|
|
35
|
+
customHeaders: this.customHeaders,
|
|
36
|
+
});
|
|
37
|
+
return validateProjectHealth(response.data);
|
|
38
|
+
}
|
|
39
|
+
async getProjectHealthContext(projectId) {
|
|
40
|
+
IdSchema.parse(projectId);
|
|
41
|
+
const response = await request({
|
|
42
|
+
httpMethod: 'GET',
|
|
43
|
+
baseUri: this.syncApiBase,
|
|
44
|
+
relativePath: getProjectInsightsHealthContextEndpoint(projectId),
|
|
45
|
+
apiToken: this.authToken,
|
|
46
|
+
customFetch: this.customFetch,
|
|
47
|
+
customHeaders: this.customHeaders,
|
|
48
|
+
});
|
|
49
|
+
return validateProjectHealthContext(response.data);
|
|
50
|
+
}
|
|
51
|
+
async getProjectProgress(projectId) {
|
|
52
|
+
IdSchema.parse(projectId);
|
|
53
|
+
const response = await request({
|
|
54
|
+
httpMethod: 'GET',
|
|
55
|
+
baseUri: this.syncApiBase,
|
|
56
|
+
relativePath: getProjectInsightsProgressEndpoint(projectId),
|
|
57
|
+
apiToken: this.authToken,
|
|
58
|
+
customFetch: this.customFetch,
|
|
59
|
+
customHeaders: this.customHeaders,
|
|
60
|
+
});
|
|
61
|
+
return validateProjectProgress(response.data);
|
|
62
|
+
}
|
|
63
|
+
async getWorkspaceInsights(workspaceId, args = {}) {
|
|
64
|
+
IdSchema.parse(workspaceId);
|
|
65
|
+
const response = await request({
|
|
66
|
+
httpMethod: 'GET',
|
|
67
|
+
baseUri: this.syncApiBase,
|
|
68
|
+
relativePath: getWorkspaceInsightsEndpoint(workspaceId),
|
|
69
|
+
apiToken: this.authToken,
|
|
70
|
+
customFetch: this.customFetch,
|
|
71
|
+
customHeaders: this.customHeaders,
|
|
72
|
+
payload: Object.assign(Object.assign({}, args), (args.projectIds ? { projectIds: args.projectIds.join(',') } : {})),
|
|
73
|
+
});
|
|
74
|
+
return validateWorkspaceInsights(response.data);
|
|
75
|
+
}
|
|
76
|
+
async analyzeProjectHealth(projectId, requestId) {
|
|
77
|
+
IdSchema.parse(projectId);
|
|
78
|
+
const response = await request({
|
|
79
|
+
httpMethod: 'POST',
|
|
80
|
+
baseUri: this.syncApiBase,
|
|
81
|
+
relativePath: getProjectInsightsHealthAnalyzeEndpoint(projectId),
|
|
82
|
+
apiToken: this.authToken,
|
|
83
|
+
customFetch: this.customFetch,
|
|
84
|
+
customHeaders: this.customHeaders,
|
|
85
|
+
requestId: requestId,
|
|
86
|
+
});
|
|
87
|
+
return validateProjectHealth(response.data);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { ENDPOINT_REST_LABELS, ENDPOINT_REST_LABELS_SEARCH, ENDPOINT_REST_LABELS_SHARED, ENDPOINT_REST_LABELS_SHARED_REMOVE, ENDPOINT_REST_LABELS_SHARED_RENAME, } from '../consts/endpoints.js';
|
|
2
|
+
import { isSuccess, request } from '../transport/http-client.js';
|
|
3
|
+
import { generatePath } from '../utils/request-helpers.js';
|
|
4
|
+
import { IdSchema, validateLabel, validateLabelArray } from '../utils/validators.js';
|
|
5
|
+
import { BaseClient } from './base-client.js';
|
|
6
|
+
/**
|
|
7
|
+
* Internal sub-client handling all label-domain endpoints.
|
|
8
|
+
*
|
|
9
|
+
* Instantiated by `TodoistApi`; every public label method on `TodoistApi`
|
|
10
|
+
* delegates here. See `todoist-api.ts` for the user-facing JSDoc.
|
|
11
|
+
*/
|
|
12
|
+
export class LabelClient extends BaseClient {
|
|
13
|
+
async getLabel(id) {
|
|
14
|
+
IdSchema.parse(id);
|
|
15
|
+
const response = await request({
|
|
16
|
+
httpMethod: 'GET',
|
|
17
|
+
baseUri: this.syncApiBase,
|
|
18
|
+
relativePath: generatePath(ENDPOINT_REST_LABELS, id),
|
|
19
|
+
apiToken: this.authToken,
|
|
20
|
+
customFetch: this.customFetch,
|
|
21
|
+
customHeaders: this.customHeaders,
|
|
22
|
+
});
|
|
23
|
+
return validateLabel(response.data);
|
|
24
|
+
}
|
|
25
|
+
async getLabels(args = {}) {
|
|
26
|
+
const { data: { results, nextCursor }, } = await request({
|
|
27
|
+
httpMethod: 'GET',
|
|
28
|
+
baseUri: this.syncApiBase,
|
|
29
|
+
relativePath: ENDPOINT_REST_LABELS,
|
|
30
|
+
apiToken: this.authToken,
|
|
31
|
+
customFetch: this.customFetch,
|
|
32
|
+
customHeaders: this.customHeaders,
|
|
33
|
+
payload: args,
|
|
34
|
+
});
|
|
35
|
+
return {
|
|
36
|
+
results: validateLabelArray(results),
|
|
37
|
+
nextCursor,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
async searchLabels(args) {
|
|
41
|
+
const { data: { results, nextCursor }, } = await request({
|
|
42
|
+
httpMethod: 'GET',
|
|
43
|
+
baseUri: this.syncApiBase,
|
|
44
|
+
relativePath: ENDPOINT_REST_LABELS_SEARCH,
|
|
45
|
+
apiToken: this.authToken,
|
|
46
|
+
customFetch: this.customFetch,
|
|
47
|
+
customHeaders: this.customHeaders,
|
|
48
|
+
payload: args,
|
|
49
|
+
});
|
|
50
|
+
return {
|
|
51
|
+
results: validateLabelArray(results),
|
|
52
|
+
nextCursor,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
async addLabel(args, requestId) {
|
|
56
|
+
const response = await request({
|
|
57
|
+
httpMethod: 'POST',
|
|
58
|
+
baseUri: this.syncApiBase,
|
|
59
|
+
relativePath: ENDPOINT_REST_LABELS,
|
|
60
|
+
apiToken: this.authToken,
|
|
61
|
+
customFetch: this.customFetch,
|
|
62
|
+
customHeaders: this.customHeaders,
|
|
63
|
+
payload: args,
|
|
64
|
+
requestId: requestId,
|
|
65
|
+
});
|
|
66
|
+
return validateLabel(response.data);
|
|
67
|
+
}
|
|
68
|
+
async updateLabel(id, args, requestId) {
|
|
69
|
+
IdSchema.parse(id);
|
|
70
|
+
const response = await request({
|
|
71
|
+
httpMethod: 'POST',
|
|
72
|
+
baseUri: this.syncApiBase,
|
|
73
|
+
relativePath: generatePath(ENDPOINT_REST_LABELS, id),
|
|
74
|
+
apiToken: this.authToken,
|
|
75
|
+
customFetch: this.customFetch,
|
|
76
|
+
customHeaders: this.customHeaders,
|
|
77
|
+
payload: args,
|
|
78
|
+
requestId: requestId,
|
|
79
|
+
});
|
|
80
|
+
return validateLabel(response.data);
|
|
81
|
+
}
|
|
82
|
+
async deleteLabel(id, requestId) {
|
|
83
|
+
IdSchema.parse(id);
|
|
84
|
+
const response = await request({
|
|
85
|
+
httpMethod: 'DELETE',
|
|
86
|
+
baseUri: this.syncApiBase,
|
|
87
|
+
relativePath: generatePath(ENDPOINT_REST_LABELS, id),
|
|
88
|
+
apiToken: this.authToken,
|
|
89
|
+
customFetch: this.customFetch,
|
|
90
|
+
customHeaders: this.customHeaders,
|
|
91
|
+
requestId: requestId,
|
|
92
|
+
});
|
|
93
|
+
return isSuccess(response);
|
|
94
|
+
}
|
|
95
|
+
async getSharedLabels(args) {
|
|
96
|
+
const { data: { results, nextCursor }, } = await request({
|
|
97
|
+
httpMethod: 'GET',
|
|
98
|
+
baseUri: this.syncApiBase,
|
|
99
|
+
relativePath: ENDPOINT_REST_LABELS_SHARED,
|
|
100
|
+
apiToken: this.authToken,
|
|
101
|
+
customFetch: this.customFetch,
|
|
102
|
+
customHeaders: this.customHeaders,
|
|
103
|
+
payload: args,
|
|
104
|
+
});
|
|
105
|
+
return { results, nextCursor };
|
|
106
|
+
}
|
|
107
|
+
async renameSharedLabel(args) {
|
|
108
|
+
const response = await request({
|
|
109
|
+
httpMethod: 'POST',
|
|
110
|
+
baseUri: this.syncApiBase,
|
|
111
|
+
relativePath: ENDPOINT_REST_LABELS_SHARED_RENAME,
|
|
112
|
+
apiToken: this.authToken,
|
|
113
|
+
customFetch: this.customFetch,
|
|
114
|
+
customHeaders: this.customHeaders,
|
|
115
|
+
payload: args,
|
|
116
|
+
});
|
|
117
|
+
return isSuccess(response);
|
|
118
|
+
}
|
|
119
|
+
async removeSharedLabel(args) {
|
|
120
|
+
const response = await request({
|
|
121
|
+
httpMethod: 'POST',
|
|
122
|
+
baseUri: this.syncApiBase,
|
|
123
|
+
relativePath: ENDPOINT_REST_LABELS_SHARED_REMOVE,
|
|
124
|
+
apiToken: this.authToken,
|
|
125
|
+
customFetch: this.customFetch,
|
|
126
|
+
customHeaders: this.customHeaders,
|
|
127
|
+
payload: args,
|
|
128
|
+
});
|
|
129
|
+
return isSuccess(response);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ENDPOINT_REST_PRODUCTIVITY } from '../consts/endpoints.js';
|
|
2
|
+
import { request } from '../transport/http-client.js';
|
|
3
|
+
import { validateProductivityStats } from '../utils/validators.js';
|
|
4
|
+
import { BaseClient } from './base-client.js';
|
|
5
|
+
/**
|
|
6
|
+
* Internal sub-client handling the productivity-stats endpoint.
|
|
7
|
+
*
|
|
8
|
+
* Instantiated by `TodoistApi`; the public `getProductivityStats` method
|
|
9
|
+
* on `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
|
|
10
|
+
* JSDoc.
|
|
11
|
+
*/
|
|
12
|
+
export class ProductivityClient extends BaseClient {
|
|
13
|
+
async getProductivityStats() {
|
|
14
|
+
const response = await request({
|
|
15
|
+
httpMethod: 'GET',
|
|
16
|
+
baseUri: this.syncApiBase,
|
|
17
|
+
relativePath: ENDPOINT_REST_PRODUCTIVITY,
|
|
18
|
+
apiToken: this.authToken,
|
|
19
|
+
customFetch: this.customFetch,
|
|
20
|
+
customHeaders: this.customHeaders,
|
|
21
|
+
});
|
|
22
|
+
return validateProductivityStats(response.data);
|
|
23
|
+
}
|
|
24
|
+
}
|