@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,255 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { StringOrNumberSchema } from '../common.js';
|
|
3
|
+
import { UI_EXTENSION_TYPES } from '../ui-extensions/types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Available statuses for a developer application.
|
|
6
|
+
*/
|
|
7
|
+
export const APP_STATUSES = ['public'];
|
|
8
|
+
export const AppStatusSchema = z.enum(APP_STATUSES);
|
|
9
|
+
/**
|
|
10
|
+
* Webhook event types that can be subscribed to.
|
|
11
|
+
*
|
|
12
|
+
* These are the friendly public names the backend uses in webhook payloads.
|
|
13
|
+
* The on-the-wire config endpoint uses a different (legacy) form (see
|
|
14
|
+
* {@link WEBHOOK_EVENT_WIRE_NAMES}); the SDK converts between the two
|
|
15
|
+
* so consumers only ever work with these pretty names.
|
|
16
|
+
*
|
|
17
|
+
* @see https://developer.todoist.com/sync/v1/#webhooks
|
|
18
|
+
*/
|
|
19
|
+
export const WEBHOOK_EVENTS = [
|
|
20
|
+
'item:added',
|
|
21
|
+
'item:updated',
|
|
22
|
+
'item:completed',
|
|
23
|
+
'item:uncompleted',
|
|
24
|
+
'item:deleted',
|
|
25
|
+
'note:added',
|
|
26
|
+
'note:updated',
|
|
27
|
+
'note:deleted',
|
|
28
|
+
'project:added',
|
|
29
|
+
'project:updated',
|
|
30
|
+
'project:deleted',
|
|
31
|
+
'project:archived',
|
|
32
|
+
'project:unarchived',
|
|
33
|
+
'section:added',
|
|
34
|
+
'section:updated',
|
|
35
|
+
'section:deleted',
|
|
36
|
+
'section:archived',
|
|
37
|
+
'section:unarchived',
|
|
38
|
+
'label:added',
|
|
39
|
+
'label:updated',
|
|
40
|
+
'label:deleted',
|
|
41
|
+
'filter:added',
|
|
42
|
+
'filter:updated',
|
|
43
|
+
'filter:deleted',
|
|
44
|
+
'reminder:fired',
|
|
45
|
+
];
|
|
46
|
+
export const WebhookEventSchema = z.enum(WEBHOOK_EVENTS);
|
|
47
|
+
/**
|
|
48
|
+
* Raw wire-format webhook event names used by the config endpoint
|
|
49
|
+
* (`POST/GET /apps/<id>/webhook`). Exported for completeness — prefer
|
|
50
|
+
* {@link WEBHOOK_EVENTS} when working with the SDK.
|
|
51
|
+
*/
|
|
52
|
+
export const WEBHOOK_EVENT_WIRE_NAMES = [
|
|
53
|
+
'e_item_added',
|
|
54
|
+
'e_item_updated',
|
|
55
|
+
'e_item_completed',
|
|
56
|
+
'e_item_uncompleted',
|
|
57
|
+
'e_item_deleted',
|
|
58
|
+
'e_note_added',
|
|
59
|
+
'e_note_updated',
|
|
60
|
+
'e_note_deleted',
|
|
61
|
+
'e_project_added',
|
|
62
|
+
'e_project_updated',
|
|
63
|
+
'e_project_deleted',
|
|
64
|
+
'e_project_archived',
|
|
65
|
+
'e_project_unarchived',
|
|
66
|
+
'e_section_added',
|
|
67
|
+
'e_section_updated',
|
|
68
|
+
'e_section_deleted',
|
|
69
|
+
'e_section_archived',
|
|
70
|
+
'e_section_unarchived',
|
|
71
|
+
'e_label_added',
|
|
72
|
+
'e_label_updated',
|
|
73
|
+
'e_label_deleted',
|
|
74
|
+
'e_filter_added',
|
|
75
|
+
'e_filter_updated',
|
|
76
|
+
'e_filter_deleted',
|
|
77
|
+
'e_reminder_fired',
|
|
78
|
+
];
|
|
79
|
+
export const WebhookEventWireNameSchema = z.enum(WEBHOOK_EVENT_WIRE_NAMES);
|
|
80
|
+
/**
|
|
81
|
+
* Translates a wire-format event name (`'e_item_added'`) to its pretty form (`'item:added'`).
|
|
82
|
+
*/
|
|
83
|
+
export function webhookEventFromWireName(wireName) {
|
|
84
|
+
// Strip leading `e_`, replace first `_` with `:`. The resulting string is
|
|
85
|
+
// guaranteed to be a `WebhookEvent` by construction of the two const arrays.
|
|
86
|
+
return wireName.slice(2).replace('_', ':');
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Translates a pretty event name (`'item:added'`) to its wire-format form (`'e_item_added'`).
|
|
90
|
+
*/
|
|
91
|
+
export function webhookEventToWireName(event) {
|
|
92
|
+
return ('e_' + event.replace(':', '_'));
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Available statuses for an app webhook.
|
|
96
|
+
*/
|
|
97
|
+
export const WEBHOOK_STATUSES = ['active', 'invalid'];
|
|
98
|
+
export const WebhookStatusSchema = z.enum(WEBHOOK_STATUSES);
|
|
99
|
+
/**
|
|
100
|
+
* Supported webhook payload versions. v9 is deprecated and intentionally excluded.
|
|
101
|
+
*/
|
|
102
|
+
export const WEBHOOK_VERSIONS = ['1'];
|
|
103
|
+
export const WebhookVersionSchema = z.enum(WEBHOOK_VERSIONS);
|
|
104
|
+
/**
|
|
105
|
+
* Available installation types for an app installation.
|
|
106
|
+
*/
|
|
107
|
+
export const INSTALLATION_TYPES = ['user'];
|
|
108
|
+
export const InstallationTypeSchema = z.enum(INSTALLATION_TYPES);
|
|
109
|
+
/**
|
|
110
|
+
* Transforms a comma-separated scope string into `string[] | null`.
|
|
111
|
+
*
|
|
112
|
+
* The backend stores `app_token_scopes` as a single comma-separated string
|
|
113
|
+
* (e.g. `"data:read,task:add"`). Reads are exposed as `string[]` (rather than
|
|
114
|
+
* `Permission[]`) so that newly added backend scopes don't break parsing —
|
|
115
|
+
* writes accept `Permission` for autocomplete while still permitting `string`
|
|
116
|
+
* (via `UpdateAppArgs`), so a fetched `App.appTokenScopes` can be round-tripped
|
|
117
|
+
* back into `updateApp()` without casts.
|
|
118
|
+
*
|
|
119
|
+
* Preserves `null` on read (backend returns `null` for apps that have had
|
|
120
|
+
* their scopes cleared via `updateApp({ appTokenScopes: null })`) so the
|
|
121
|
+
* read and write shapes line up and information is not lost.
|
|
122
|
+
*/
|
|
123
|
+
export const AppTokenScopesSchema = z
|
|
124
|
+
.string()
|
|
125
|
+
.nullable()
|
|
126
|
+
.transform((value) => {
|
|
127
|
+
if (value === null)
|
|
128
|
+
return null;
|
|
129
|
+
if (value === '')
|
|
130
|
+
return [];
|
|
131
|
+
return value.split(',').filter(Boolean);
|
|
132
|
+
});
|
|
133
|
+
/**
|
|
134
|
+
* Available OAuth client types for a developer application (RFC 6749 §2.1).
|
|
135
|
+
*/
|
|
136
|
+
export const APP_CLIENT_TYPES = ['confidential', 'public'];
|
|
137
|
+
export const AppClientTypeSchema = z.enum(APP_CLIENT_TYPES);
|
|
138
|
+
/**
|
|
139
|
+
* Schema for a developer application.
|
|
140
|
+
* @see https://developer.todoist.com/api/v1/#tag/Apps
|
|
141
|
+
*/
|
|
142
|
+
export const AppSchema = z.object({
|
|
143
|
+
id: StringOrNumberSchema,
|
|
144
|
+
clientId: z.string(),
|
|
145
|
+
status: AppStatusSchema,
|
|
146
|
+
displayName: z.string(),
|
|
147
|
+
userId: StringOrNumberSchema,
|
|
148
|
+
createdAt: z.coerce.date(),
|
|
149
|
+
serviceUrl: z.string().nullable(),
|
|
150
|
+
oauthRedirectUri: z.string().nullable(),
|
|
151
|
+
description: z.string().nullable(),
|
|
152
|
+
iconSm: z.string().nullable(),
|
|
153
|
+
iconMd: z.string().nullable(),
|
|
154
|
+
iconLg: z.string().nullable(),
|
|
155
|
+
appTokenScopes: AppTokenScopesSchema,
|
|
156
|
+
clientType: AppClientTypeSchema,
|
|
157
|
+
});
|
|
158
|
+
/**
|
|
159
|
+
* Schema for a developer application that includes the user count.
|
|
160
|
+
* Returned by most endpoints that manage a single app (get, update, delete).
|
|
161
|
+
*/
|
|
162
|
+
export const AppWithUserCountSchema = AppSchema.extend({
|
|
163
|
+
userCount: z.number().int(),
|
|
164
|
+
});
|
|
165
|
+
/**
|
|
166
|
+
* OAuth client credentials for a developer application.
|
|
167
|
+
*/
|
|
168
|
+
export const AppSecretsSchema = z.object({
|
|
169
|
+
clientId: z.string(),
|
|
170
|
+
clientSecret: z.string(),
|
|
171
|
+
});
|
|
172
|
+
/**
|
|
173
|
+
* Webhook verification token for a developer application.
|
|
174
|
+
*/
|
|
175
|
+
export const AppVerificationTokenSchema = z.object({
|
|
176
|
+
verificationToken: z.string(),
|
|
177
|
+
});
|
|
178
|
+
/**
|
|
179
|
+
* Developer test access token for a developer application.
|
|
180
|
+
*/
|
|
181
|
+
export const AppTestTokenSchema = z.object({
|
|
182
|
+
accessToken: z.string().nullish(),
|
|
183
|
+
});
|
|
184
|
+
/**
|
|
185
|
+
* Distribution token for a developer application.
|
|
186
|
+
*/
|
|
187
|
+
export const AppDistributionTokenSchema = z.object({
|
|
188
|
+
distributionToken: z.string(),
|
|
189
|
+
});
|
|
190
|
+
/**
|
|
191
|
+
* Subset of an app returned when resolving by distribution token — used by the installation flow.
|
|
192
|
+
* Includes a lightweight list of the app's UI extensions (not full `UIExtension` records).
|
|
193
|
+
*/
|
|
194
|
+
export const AppByDistributionTokenUiExtensionSchema = z.object({
|
|
195
|
+
name: z.string(),
|
|
196
|
+
description: z.string(),
|
|
197
|
+
icon: z.string().nullable(),
|
|
198
|
+
extensionType: z.enum(UI_EXTENSION_TYPES),
|
|
199
|
+
});
|
|
200
|
+
export const AppByDistributionTokenSchema = z.object({
|
|
201
|
+
id: StringOrNumberSchema,
|
|
202
|
+
displayName: z.string(),
|
|
203
|
+
description: z.string().nullable(),
|
|
204
|
+
iconMd: z.string().nullable(),
|
|
205
|
+
appTokenScopes: AppTokenScopesSchema,
|
|
206
|
+
uiExtensions: z.array(AppByDistributionTokenUiExtensionSchema),
|
|
207
|
+
});
|
|
208
|
+
/**
|
|
209
|
+
* Schema for an app webhook.
|
|
210
|
+
*
|
|
211
|
+
* Events arrive from the wire in their `e_*` form and are transformed to
|
|
212
|
+
* their pretty `item:added`-style names for SDK consumers.
|
|
213
|
+
*/
|
|
214
|
+
export const AppWebhookSchema = z.object({
|
|
215
|
+
status: WebhookStatusSchema,
|
|
216
|
+
callbackUrl: z.string(),
|
|
217
|
+
version: WebhookVersionSchema,
|
|
218
|
+
events: z.array(WebhookEventWireNameSchema.transform(webhookEventFromWireName)),
|
|
219
|
+
});
|
|
220
|
+
/**
|
|
221
|
+
* Lightweight view of an app embedded in an installation record.
|
|
222
|
+
* Mirrors `AppSchema` shape — backend returns the same `ApplicationRestView`.
|
|
223
|
+
*/
|
|
224
|
+
export const InstalledIntegrationSchema = AppSchema;
|
|
225
|
+
/**
|
|
226
|
+
* Schema for an installed application (integration installed to a user's account).
|
|
227
|
+
*/
|
|
228
|
+
export const AppInstallationSchema = z.object({
|
|
229
|
+
id: StringOrNumberSchema,
|
|
230
|
+
creator: StringOrNumberSchema,
|
|
231
|
+
createdTs: z.number().int(),
|
|
232
|
+
installationType: InstallationTypeSchema,
|
|
233
|
+
appTokenScopesValidated: z.boolean(),
|
|
234
|
+
integration: InstalledIntegrationSchema.nullable(),
|
|
235
|
+
});
|
|
236
|
+
/**
|
|
237
|
+
* Lightweight app info included on a user authorization record.
|
|
238
|
+
*/
|
|
239
|
+
export const UserAuthorizationAppSchema = z.object({
|
|
240
|
+
id: StringOrNumberSchema,
|
|
241
|
+
displayName: z.string(),
|
|
242
|
+
description: z.string().nullable(),
|
|
243
|
+
serviceUrl: z.string().nullable(),
|
|
244
|
+
iconMd: z.string().nullable(),
|
|
245
|
+
});
|
|
246
|
+
/**
|
|
247
|
+
* Schema for a user authorization entry — a token the user has granted to a third-party app.
|
|
248
|
+
*/
|
|
249
|
+
export const UserAuthorizationSchema = z.object({
|
|
250
|
+
accessTokenId: StringOrNumberSchema,
|
|
251
|
+
scope: z.array(z.string()),
|
|
252
|
+
scopeDescriptions: z.array(z.string()),
|
|
253
|
+
createdAt: z.coerce.date(),
|
|
254
|
+
app: UserAuthorizationAppSchema.nullable(),
|
|
255
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { WORKSPACE_PLAN_STATUSES } from '../workspaces/types.js';
|
|
3
|
+
/** Available subscription statuses. */
|
|
4
|
+
export const BILLING_SUBSCRIPTION_STATUSES = [
|
|
5
|
+
'none',
|
|
6
|
+
'autorenew',
|
|
7
|
+
'canceled',
|
|
8
|
+
'expired',
|
|
9
|
+
'trial',
|
|
10
|
+
'trial_canceled',
|
|
11
|
+
];
|
|
12
|
+
/** Available plan tiers. */
|
|
13
|
+
export const BILLING_PLANS = ['free', 'pro', 'pro_gifted', 'pro_legacy'];
|
|
14
|
+
/** Ways an active subscription can be purchased. */
|
|
15
|
+
export const BILLING_ACTIVATION_METHODS = [
|
|
16
|
+
'stripe',
|
|
17
|
+
'appstore',
|
|
18
|
+
'playstore',
|
|
19
|
+
'teams',
|
|
20
|
+
'manual',
|
|
21
|
+
];
|
|
22
|
+
/** Available billing cycles. */
|
|
23
|
+
export const BILLING_CYCLES = ['monthly', 'yearly'];
|
|
24
|
+
/** Available tax behaviors for a price. */
|
|
25
|
+
export const TAX_BEHAVIORS = ['exclusive', 'inclusive', 'unspecified'];
|
|
26
|
+
export const BillingPlanPriceSchema = z.object({
|
|
27
|
+
amount: z.string(),
|
|
28
|
+
rawAmount: z.number(),
|
|
29
|
+
currency: z.string(),
|
|
30
|
+
billingCycle: z.enum(BILLING_CYCLES).nullable(),
|
|
31
|
+
taxBehavior: z.enum(TAX_BEHAVIORS),
|
|
32
|
+
});
|
|
33
|
+
export const SubscriptionInfoSchema = z.object({
|
|
34
|
+
status: z.enum(BILLING_SUBSCRIPTION_STATUSES),
|
|
35
|
+
plan: z.enum(BILLING_PLANS),
|
|
36
|
+
expirationDate: z.string().nullable(),
|
|
37
|
+
activationMethod: z.enum(BILLING_ACTIVATION_METHODS),
|
|
38
|
+
planPrice: BillingPlanPriceSchema.nullable(),
|
|
39
|
+
billingPortalUrl: z.string().nullable(),
|
|
40
|
+
billingPortalSwitchToAnnualUrl: z.string().nullable(),
|
|
41
|
+
hasBillingPortal: z.boolean(),
|
|
42
|
+
hasBillingPortalSwitchToAnnual: z.boolean(),
|
|
43
|
+
invoiceCreditBalance: z.record(z.string(), z.number().int()).nullable(),
|
|
44
|
+
hasSwitchLegacyToCurrent: z.boolean(),
|
|
45
|
+
});
|
|
46
|
+
export const FormattedPriceSchema = z.object({
|
|
47
|
+
currency: z.string(),
|
|
48
|
+
unitAmount: z.number().int(),
|
|
49
|
+
taxBehavior: z.enum(TAX_BEHAVIORS),
|
|
50
|
+
});
|
|
51
|
+
export const PriceListingSchema = z.object({
|
|
52
|
+
billingCycle: z.enum(BILLING_CYCLES),
|
|
53
|
+
prices: z.array(FormattedPriceSchema),
|
|
54
|
+
});
|
|
55
|
+
export const ProPlanDetailsSchema = z.object({
|
|
56
|
+
currentPlanStatus: z.enum(WORKSPACE_PLAN_STATUSES),
|
|
57
|
+
downgradeAt: z.string().nullable(),
|
|
58
|
+
priceList: z.array(PriceListingSchema),
|
|
59
|
+
});
|
|
60
|
+
export const PricesResponseSchema = z.object({
|
|
61
|
+
pro: z.array(PriceListingSchema),
|
|
62
|
+
teams: z.array(PriceListingSchema),
|
|
63
|
+
});
|
|
64
|
+
/**
|
|
65
|
+
* Monthly and yearly amounts for a single currency. Each amount is a number in
|
|
66
|
+
* the currency's smallest unit, or a localized formatted string when the
|
|
67
|
+
* `pricing` endpoint is called with `formatted: true`.
|
|
68
|
+
*/
|
|
69
|
+
export const PricingTermsSchema = z.object({
|
|
70
|
+
monthly: z.union([z.number(), z.string()]),
|
|
71
|
+
yearly: z.union([z.number(), z.string()]),
|
|
72
|
+
});
|
|
73
|
+
/**
|
|
74
|
+
* A pricing version entry: plan name (`pro` / `biz`) → currency code →
|
|
75
|
+
* {@link PricingTerms}.
|
|
76
|
+
*/
|
|
77
|
+
export const PricingVersionSchema = z.record(z.string(), z.record(z.string(), PricingTermsSchema));
|
|
78
|
+
/**
|
|
79
|
+
* Response of the `pricing` endpoint: fixed version-pointer string fields plus
|
|
80
|
+
* dynamic version keys (`v1`, `v2`, …), each a {@link PricingVersion}.
|
|
81
|
+
*/
|
|
82
|
+
export const PricingResponseSchema = z
|
|
83
|
+
.object({
|
|
84
|
+
latestPro: z.string(),
|
|
85
|
+
latestBiz: z.string(),
|
|
86
|
+
sessionPro: z.string(),
|
|
87
|
+
sessionBiz: z.string(),
|
|
88
|
+
})
|
|
89
|
+
.catchall(PricingVersionSchema);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
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 { z } from 'zod';
|
|
13
|
+
/** Available file attachment upload states. */
|
|
14
|
+
export const UPLOAD_STATES = ['pending', 'completed'];
|
|
15
|
+
export const AttachmentSchema = z
|
|
16
|
+
.object({
|
|
17
|
+
resourceType: z.string(),
|
|
18
|
+
})
|
|
19
|
+
.extend({
|
|
20
|
+
fileName: z.string().nullable().optional(),
|
|
21
|
+
fileSize: z.number().int().nullable().optional(),
|
|
22
|
+
fileType: z.string().nullable().optional(),
|
|
23
|
+
fileUrl: z.string().nullable().optional(),
|
|
24
|
+
fileDuration: z.number().int().nullable().optional(),
|
|
25
|
+
uploadState: z.enum(UPLOAD_STATES).nullable().optional(),
|
|
26
|
+
image: z.string().nullable().optional(),
|
|
27
|
+
imageWidth: z.number().int().nullable().optional(),
|
|
28
|
+
imageHeight: z.number().int().nullable().optional(),
|
|
29
|
+
url: z.string().nullable().optional(),
|
|
30
|
+
title: z.string().nullable().optional(),
|
|
31
|
+
});
|
|
32
|
+
export const RawCommentSchema = z
|
|
33
|
+
.object({
|
|
34
|
+
id: z.string(),
|
|
35
|
+
itemId: z.string().optional(),
|
|
36
|
+
projectId: z.string().optional(),
|
|
37
|
+
content: z.string(),
|
|
38
|
+
postedAt: z.coerce.date(),
|
|
39
|
+
fileAttachment: AttachmentSchema.nullable(),
|
|
40
|
+
postedUid: z.string(),
|
|
41
|
+
uidsToNotify: z.array(z.string()).nullable(),
|
|
42
|
+
reactions: z.record(z.string(), z.array(z.string())).nullable(),
|
|
43
|
+
isDeleted: z.boolean(),
|
|
44
|
+
})
|
|
45
|
+
.refine((data) => {
|
|
46
|
+
// At least one of itemId or projectId must be present
|
|
47
|
+
return ((data.itemId !== undefined && data.projectId === undefined) ||
|
|
48
|
+
(data.itemId === undefined && data.projectId !== undefined));
|
|
49
|
+
}, {
|
|
50
|
+
message: 'Exactly one of itemId or projectId must be provided',
|
|
51
|
+
});
|
|
52
|
+
export const CommentSchema = RawCommentSchema.transform((data) => {
|
|
53
|
+
const { itemId } = data, rest = __rest(data, ["itemId"]);
|
|
54
|
+
return Object.assign(Object.assign({}, rest), {
|
|
55
|
+
// Map itemId to taskId for backwards compatibility
|
|
56
|
+
taskId: itemId });
|
|
57
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Zod schema that accepts both string and number values and coerces to string.
|
|
4
|
+
* The REST API returns numeric IDs while the Sync API returns string IDs.
|
|
5
|
+
*/
|
|
6
|
+
const StringOrNumberSchema = z.union([z.string(), z.number()]).transform((val) => String(val));
|
|
7
|
+
export { StringOrNumberSchema };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './requests.js';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { CustomError } from 'ts-custom-error';
|
|
2
|
+
const authenticationErrorCodes = [401, 403];
|
|
3
|
+
export class TodoistRequestError extends CustomError {
|
|
4
|
+
constructor(message, httpStatusCode, responseData) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.message = message;
|
|
7
|
+
this.httpStatusCode = httpStatusCode;
|
|
8
|
+
this.responseData = responseData;
|
|
9
|
+
this.isAuthenticationError = () => {
|
|
10
|
+
if (!this.httpStatusCode) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
return authenticationErrorCodes.includes(this.httpStatusCode);
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(this, 'name', { value: 'TodoistRequestError' });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Thrown when the Sync API accepts a request but one or more of its commands fail.
|
|
20
|
+
*
|
|
21
|
+
* Sync commands are applied independently, so the commands that succeeded have
|
|
22
|
+
* already taken effect. `message`, `httpStatusCode` and `responseData` describe the
|
|
23
|
+
* first failed command, as on a plain {@link TodoistRequestError}, while
|
|
24
|
+
* `syncStatus` and `tempIdMapping` cover every command in the request, so callers
|
|
25
|
+
* can tell which ones were applied.
|
|
26
|
+
*/
|
|
27
|
+
export class TodoistSyncError extends TodoistRequestError {
|
|
28
|
+
constructor(firstFailure, { syncStatus, tempIdMapping }) {
|
|
29
|
+
super(firstFailure.error, firstFailure.httpCode, firstFailure.errorExtra);
|
|
30
|
+
Object.defineProperty(this, 'name', { value: 'TodoistSyncError' });
|
|
31
|
+
this.syncStatus = syncStatus;
|
|
32
|
+
this.tempIdMapping = tempIdMapping;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export class TodoistArgumentError extends CustomError {
|
|
36
|
+
constructor(message) {
|
|
37
|
+
super(message);
|
|
38
|
+
this.message = message;
|
|
39
|
+
Object.defineProperty(this, 'name', { value: 'TodoistArgumentError' });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './requests.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type guard to check if an error is a network error
|
|
3
|
+
*/
|
|
4
|
+
export function isNetworkError(error) {
|
|
5
|
+
// Network errors in fetch are typically TypeError with specific messages.
|
|
6
|
+
// Timeout errors are created by fetch-with-retry with the TimeoutError name.
|
|
7
|
+
return ((error instanceof TypeError &&
|
|
8
|
+
(error.message.includes('fetch') ||
|
|
9
|
+
error.message.includes('network') ||
|
|
10
|
+
error.message.includes('Failed to fetch') ||
|
|
11
|
+
error.message.includes('NetworkError'))) ||
|
|
12
|
+
error.name === 'TimeoutError' ||
|
|
13
|
+
error.isNetworkError === true);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Type guard to check if an error is an HTTP error
|
|
17
|
+
*/
|
|
18
|
+
export function isHttpError(error) {
|
|
19
|
+
return 'status' in error && typeof error.status === 'number';
|
|
20
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Object types that support ID mappings. */
|
|
2
|
+
export const ID_MAPPING_OBJECT_TYPES = [
|
|
3
|
+
'sections',
|
|
4
|
+
'tasks',
|
|
5
|
+
'comments',
|
|
6
|
+
'reminders',
|
|
7
|
+
'location_reminders',
|
|
8
|
+
'projects',
|
|
9
|
+
];
|
|
10
|
+
/** Object types that support moved ID lookups. */
|
|
11
|
+
export const MOVED_ID_OBJECT_TYPES = [
|
|
12
|
+
'sections',
|
|
13
|
+
'tasks',
|
|
14
|
+
'comments',
|
|
15
|
+
'reminders',
|
|
16
|
+
'location_reminders',
|
|
17
|
+
];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export * from './tasks/index.js';
|
|
2
|
+
export * from './projects/index.js';
|
|
3
|
+
export * from './sections/index.js';
|
|
4
|
+
export * from './labels/index.js';
|
|
5
|
+
export * from './comments/index.js';
|
|
6
|
+
export * from './reminders/index.js';
|
|
7
|
+
export * from './users/index.js';
|
|
8
|
+
export * from './productivity/index.js';
|
|
9
|
+
export * from './activity/index.js';
|
|
10
|
+
export * from './workspaces/index.js';
|
|
11
|
+
export * from './folders/index.js';
|
|
12
|
+
export * from './billing/index.js';
|
|
13
|
+
export * from './insights/index.js';
|
|
14
|
+
export * from './backups/index.js';
|
|
15
|
+
export * from './id-mappings/index.js';
|
|
16
|
+
export * from './emails/index.js';
|
|
17
|
+
export * from './uploads/index.js';
|
|
18
|
+
export * from './templates/index.js';
|
|
19
|
+
export * from './errors.js';
|
|
20
|
+
export * from './http.js';
|
|
21
|
+
export * from './sync/index.js';
|
|
22
|
+
export * from './apps/index.js';
|
|
23
|
+
export * from './ui-extensions/index.js';
|
|
24
|
+
export * from './webhooks/index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const DayActivitySchema = z.object({
|
|
3
|
+
// Kept as string: this is a calendar-day bucket (e.g. '2025-01-13'), not a timestamp.
|
|
4
|
+
// Coercing to Date would create UTC midnight, causing day-shift for non-UTC consumers.
|
|
5
|
+
date: z.string(),
|
|
6
|
+
totalCount: z.number().int(),
|
|
7
|
+
});
|
|
8
|
+
export const WeekRollupSchema = z.object({
|
|
9
|
+
fromDate: z.string(),
|
|
10
|
+
toDate: z.string(),
|
|
11
|
+
totalCount: z.number().int(),
|
|
12
|
+
});
|
|
13
|
+
export const ProjectActivityStatsSchema = z.object({
|
|
14
|
+
dayItems: z.array(DayActivitySchema),
|
|
15
|
+
weekItems: z.array(WeekRollupSchema).nullable(),
|
|
16
|
+
});
|
|
17
|
+
/** Available project health statuses. */
|
|
18
|
+
export const HEALTH_STATUSES = [
|
|
19
|
+
'UNKNOWN',
|
|
20
|
+
'ON_TRACK',
|
|
21
|
+
'AT_RISK',
|
|
22
|
+
'CRITICAL',
|
|
23
|
+
'EXCELLENT',
|
|
24
|
+
'ERROR',
|
|
25
|
+
];
|
|
26
|
+
export const ProjectHealthSchema = z.object({
|
|
27
|
+
status: z.enum(HEALTH_STATUSES),
|
|
28
|
+
description: z.string().nullable().optional(),
|
|
29
|
+
descriptionSummary: z.string().nullable().optional(),
|
|
30
|
+
projectId: z.string().nullable().optional(),
|
|
31
|
+
updatedAt: z.coerce.date().nullable().optional(),
|
|
32
|
+
isStale: z.boolean().default(false),
|
|
33
|
+
updateInProgress: z.boolean().default(false),
|
|
34
|
+
});
|
|
35
|
+
export const ProjectMetricsSchema = z.object({
|
|
36
|
+
totalTasks: z.number().int(),
|
|
37
|
+
completedTasks: z.number().int(),
|
|
38
|
+
overdueTasks: z.number().int(),
|
|
39
|
+
tasksCreatedThisWeek: z.number().int(),
|
|
40
|
+
tasksCompletedThisWeek: z.number().int(),
|
|
41
|
+
averageCompletionTime: z.number().nullable(),
|
|
42
|
+
});
|
|
43
|
+
export const TaskContextSchema = z.object({
|
|
44
|
+
id: z.string(),
|
|
45
|
+
content: z.string(),
|
|
46
|
+
due: z.string().nullable().optional(),
|
|
47
|
+
deadline: z.string().nullable().optional(),
|
|
48
|
+
priority: z.string(),
|
|
49
|
+
isCompleted: z.boolean(),
|
|
50
|
+
createdAt: z.coerce.date(),
|
|
51
|
+
updatedAt: z.coerce.date(),
|
|
52
|
+
completedAt: z.coerce.date().nullable(),
|
|
53
|
+
completedByUid: z.string().nullable(),
|
|
54
|
+
labels: z.array(z.string()),
|
|
55
|
+
});
|
|
56
|
+
export const ProjectHealthContextSchema = z.object({
|
|
57
|
+
projectId: z.string(),
|
|
58
|
+
projectName: z.string(),
|
|
59
|
+
projectDescription: z.string().nullable(),
|
|
60
|
+
projectMetrics: ProjectMetricsSchema,
|
|
61
|
+
tasks: z.array(TaskContextSchema),
|
|
62
|
+
language: z.string().nullable().optional(),
|
|
63
|
+
});
|
|
64
|
+
export const ProjectProgressSchema = z.object({
|
|
65
|
+
projectId: z.string(),
|
|
66
|
+
completedCount: z.number().int(),
|
|
67
|
+
activeCount: z.number().int(),
|
|
68
|
+
progressPercent: z.number().int(),
|
|
69
|
+
});
|
|
70
|
+
export const ProjectInsightSchema = z.object({
|
|
71
|
+
projectId: z.string(),
|
|
72
|
+
health: ProjectHealthSchema.nullable(),
|
|
73
|
+
progress: ProjectProgressSchema.nullable(),
|
|
74
|
+
});
|
|
75
|
+
export const WorkspaceInsightsSchema = z.object({
|
|
76
|
+
projectInsights: z.array(ProjectInsightSchema),
|
|
77
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|