@doist/todoist-sdk 9.0.0 → 9.1.0-next.2

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.
Files changed (103) hide show
  1. package/dist/cjs/clients/activity-client.js +63 -0
  2. package/dist/cjs/clients/backup-client.js +65 -0
  3. package/dist/cjs/clients/base-client.js +30 -0
  4. package/dist/cjs/clients/comment-client.js +92 -0
  5. package/dist/cjs/clients/email-client.js +43 -0
  6. package/dist/cjs/clients/folder-client.js +80 -0
  7. package/dist/cjs/clients/goals-client.js +145 -0
  8. package/dist/cjs/clients/id-mapping-client.js +39 -0
  9. package/dist/cjs/clients/insights-client.js +88 -0
  10. package/dist/cjs/clients/label-client.js +127 -0
  11. package/dist/cjs/clients/productivity-client.js +27 -0
  12. package/dist/cjs/clients/project-client.js +232 -0
  13. package/dist/cjs/clients/reminder-client.js +198 -0
  14. package/dist/cjs/clients/section-client.js +118 -0
  15. package/dist/cjs/clients/task-client.js +255 -0
  16. package/dist/cjs/clients/template-client.js +89 -0
  17. package/dist/cjs/clients/upload-client.js +102 -0
  18. package/dist/cjs/clients/workspace-client.js +367 -0
  19. package/dist/cjs/consts/endpoints.js +6 -1
  20. package/dist/cjs/test-utils/test-defaults.js +25 -1
  21. package/dist/cjs/todoist-api.js +186 -1537
  22. package/dist/cjs/transport/sync-request.js +75 -0
  23. package/dist/cjs/types/goals/index.js +18 -0
  24. package/dist/cjs/types/goals/requests.js +2 -0
  25. package/dist/cjs/types/goals/types.js +56 -0
  26. package/dist/cjs/types/index.js +1 -0
  27. package/dist/cjs/types/sync/commands/goals.js +2 -0
  28. package/dist/cjs/types/sync/commands/index.js +1 -0
  29. package/dist/cjs/types/sync/resource-types.js +1 -0
  30. package/dist/cjs/types/sync/response.js +12 -10
  31. package/dist/cjs/utils/headers.js +16 -0
  32. package/dist/cjs/utils/request-helpers.js +21 -0
  33. package/dist/cjs/utils/validators.js +48 -46
  34. package/dist/esm/clients/activity-client.js +59 -0
  35. package/dist/esm/clients/backup-client.js +61 -0
  36. package/dist/esm/clients/base-client.js +26 -0
  37. package/dist/esm/clients/comment-client.js +88 -0
  38. package/dist/esm/clients/email-client.js +39 -0
  39. package/dist/esm/clients/folder-client.js +76 -0
  40. package/dist/esm/clients/goals-client.js +141 -0
  41. package/dist/esm/clients/id-mapping-client.js +35 -0
  42. package/dist/esm/clients/insights-client.js +84 -0
  43. package/dist/esm/clients/label-client.js +123 -0
  44. package/dist/esm/clients/productivity-client.js +23 -0
  45. package/dist/esm/clients/project-client.js +228 -0
  46. package/dist/esm/clients/reminder-client.js +194 -0
  47. package/dist/esm/clients/section-client.js +114 -0
  48. package/dist/esm/clients/task-client.js +251 -0
  49. package/dist/esm/clients/template-client.js +85 -0
  50. package/dist/esm/clients/upload-client.js +98 -0
  51. package/dist/esm/clients/workspace-client.js +363 -0
  52. package/dist/esm/consts/endpoints.js +5 -0
  53. package/dist/esm/test-utils/test-defaults.js +24 -0
  54. package/dist/esm/todoist-api.js +189 -1540
  55. package/dist/esm/transport/sync-request.js +72 -0
  56. package/dist/esm/types/goals/index.js +2 -0
  57. package/dist/esm/types/goals/requests.js +1 -0
  58. package/dist/esm/types/goals/types.js +53 -0
  59. package/dist/esm/types/index.js +1 -0
  60. package/dist/esm/types/sync/commands/goals.js +1 -0
  61. package/dist/esm/types/sync/commands/index.js +1 -0
  62. package/dist/esm/types/sync/resource-types.js +1 -0
  63. package/dist/esm/types/sync/response.js +2 -0
  64. package/dist/esm/utils/headers.js +13 -0
  65. package/dist/esm/utils/request-helpers.js +17 -0
  66. package/dist/esm/utils/validators.js +2 -0
  67. package/dist/types/clients/activity-client.d.ts +12 -0
  68. package/dist/types/clients/backup-client.d.ts +14 -0
  69. package/dist/types/clients/base-client.d.ts +21 -0
  70. package/dist/types/clients/comment-client.d.ts +15 -0
  71. package/dist/types/clients/email-client.d.ts +13 -0
  72. package/dist/types/clients/folder-client.d.ts +16 -0
  73. package/dist/types/clients/goals-client.d.ts +20 -0
  74. package/dist/types/clients/id-mapping-client.d.ts +13 -0
  75. package/dist/types/clients/insights-client.d.ts +18 -0
  76. package/dist/types/clients/label-client.d.ts +19 -0
  77. package/dist/types/clients/productivity-client.d.ts +12 -0
  78. package/dist/types/clients/project-client.d.ts +26 -0
  79. package/dist/types/clients/reminder-client.d.ts +25 -0
  80. package/dist/types/clients/section-client.d.ts +18 -0
  81. package/dist/types/clients/task-client.d.ts +25 -0
  82. package/dist/types/clients/template-client.d.ts +17 -0
  83. package/dist/types/clients/upload-client.d.ts +17 -0
  84. package/dist/types/clients/workspace-client.d.ts +43 -0
  85. package/dist/types/consts/endpoints.d.ts +5 -0
  86. package/dist/types/test-utils/test-defaults.d.ts +4 -1
  87. package/dist/types/todoist-api.d.ts +48 -17
  88. package/dist/types/transport/sync-request.d.ts +27 -0
  89. package/dist/types/types/goals/index.d.ts +2 -0
  90. package/dist/types/types/goals/requests.d.ts +33 -0
  91. package/dist/types/types/goals/types.d.ts +51 -0
  92. package/dist/types/types/http.d.ts +7 -0
  93. package/dist/types/types/index.d.ts +1 -0
  94. package/dist/types/types/sync/commands/goals.d.ts +33 -0
  95. package/dist/types/types/sync/commands/index.d.ts +9 -0
  96. package/dist/types/types/sync/resource-types.d.ts +1 -1
  97. package/dist/types/types/sync/resources/view-options.d.ts +6 -6
  98. package/dist/types/types/sync/response.d.ts +29 -4
  99. package/dist/types/types/tasks/requests.d.ts +1 -0
  100. package/dist/types/utils/headers.d.ts +7 -0
  101. package/dist/types/utils/request-helpers.d.ts +13 -0
  102. package/dist/types/utils/validators.d.ts +55 -8
  103. package/package.json +1 -1
@@ -4,7 +4,8 @@ import { Backup, GetBackupsArgs, DownloadBackupArgs } from './types/backups/inde
4
4
  import { Attachment, Comment, AddCommentArgs, UpdateCommentArgs, GetProjectCommentsArgs, GetTaskCommentsArgs, GetCommentsResponse } from './types/comments/index.js';
5
5
  import { GetOrCreateEmailArgs, GetOrCreateEmailResponse, DisableEmailArgs } from './types/emails/index.js';
6
6
  import { GetFoldersArgs, GetFoldersResponse, AddFolderArgs, UpdateFolderArgs } from './types/folders/index.js';
7
- import { CustomFetch, CustomFetchResponse } from './types/http.js';
7
+ import type { AddGoalArgs, GetGoalsArgs, GetGoalsResponse, Goal, SearchGoalsArgs, TaskLinkingArgs, UpdateGoalArgs } from './types/goals/index.js';
8
+ import { CustomFetch, FileResponse } from './types/http.js';
8
9
  import { IdMapping, MovedId, GetIdMappingsArgs, GetMovedIdsArgs } from './types/id-mappings/index.js';
9
10
  import { ProjectActivityStats, ProjectHealth, ProjectHealthContext, ProjectProgress, WorkspaceInsights, GetProjectActivityStatsArgs, GetWorkspaceInsightsArgs } from './types/insights/index.js';
10
11
  import { Label, AddLabelArgs, UpdateLabelArgs, GetLabelsArgs, SearchLabelsArgs, GetLabelsResponse, GetSharedLabelsArgs, GetSharedLabelsResponse, RenameSharedLabelArgs, RemoveSharedLabelArgs } from './types/labels/index.js';
@@ -20,12 +21,26 @@ import { CurrentUser } from './types/users/index.js';
20
21
  import { WorkspaceInvitation, WorkspacePlanDetails, JoinWorkspaceResult, Workspace, AddWorkspaceArgs, UpdateWorkspaceArgs, GetWorkspaceMembersActivityArgs, GetWorkspaceMembersActivityResponse, GetWorkspaceUserTasksArgs, GetWorkspaceUserTasksResponse, InviteWorkspaceUsersArgs, InviteWorkspaceUsersResponse, UpdateWorkspaceUserArgs, RemoveWorkspaceUserArgs, GetWorkspaceInvitationsArgs, DeleteWorkspaceInvitationArgs, WorkspaceInvitationActionArgs, JoinWorkspaceArgs, WorkspaceLogoArgs, GetWorkspacePlanDetailsArgs, GetWorkspaceUsersArgs, GetWorkspaceUsersResponse, GetWorkspaceProjectsArgs, WorkspaceInvitationsResponse, AllWorkspaceInvitationsResponse, WorkspaceLogoResponse } from './types/workspaces/index.js';
21
22
  import { type SyncResponse, type SyncRequest } from './types/sync/index.js';
22
23
  /**
23
- * Response from viewAttachment, extending CustomFetchResponse with
24
- * arrayBuffer() support for binary file content.
24
+ * A client for interacting with the Todoist API v1.
25
+ * This class provides methods to manage tasks, projects, sections, labels, and comments in Todoist.
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * const api = new TodoistApi('your-api-token');
30
+ *
31
+ * // Get all tasks
32
+ * const tasks = await api.getTasks();
33
+ *
34
+ * // Create a new task
35
+ * const newTask = await api.addTask({
36
+ * content: 'My new task',
37
+ * projectId: '12345'
38
+ * });
39
+ * ```
40
+ *
41
+ * For more information about the Todoist API v1, see the [official documentation](https://todoist.com/api/v1).
42
+ * If you're migrating from v9, please refer to the [migration guide](https://todoist.com/api/v1/docs#tag/Migrating-from-v9).
25
43
  */
26
- export type FileResponse = CustomFetchResponse & {
27
- arrayBuffer(): Promise<ArrayBuffer>;
28
- };
29
44
  /**
30
45
  * Configuration options for the TodoistApi constructor
31
46
  */
@@ -43,6 +58,23 @@ export declare class TodoistApi {
43
58
  private authToken;
44
59
  private syncApiBase;
45
60
  private customFetch?;
61
+ private readonly taskClient;
62
+ private readonly projectClient;
63
+ private readonly sectionClient;
64
+ private readonly labelClient;
65
+ private readonly commentClient;
66
+ private readonly reminderClient;
67
+ private readonly insightsClient;
68
+ private readonly folderClient;
69
+ private readonly templateClient;
70
+ private readonly uploadClient;
71
+ private readonly backupClient;
72
+ private readonly emailClient;
73
+ private readonly idMappingClient;
74
+ private readonly activityClient;
75
+ private readonly productivityClient;
76
+ private readonly workspaceClient;
77
+ private readonly goalsClient;
46
78
  constructor(
47
79
  /**
48
80
  * Your Todoist API token.
@@ -52,16 +84,6 @@ export declare class TodoistApi {
52
84
  * Optional configuration options
53
85
  */
54
86
  options?: TodoistApiOptions);
55
- /**
56
- * Makes a request to the Sync API and handles error checking.
57
- *
58
- * @param syncRequest - The sync request payload
59
- * @param requestId - Optional request identifier
60
- * @param hasSyncCommands - Whether this request contains sync commands (write operations)
61
- * @returns The sync response data
62
- * @throws TodoistRequestError if sync status contains errors
63
- */
64
- private requestSync;
65
87
  /**
66
88
  * Executes a raw Sync API request.
67
89
  *
@@ -763,6 +785,16 @@ export declare class TodoistApi {
763
785
  * @returns A promise that resolves to `true` if successful.
764
786
  */
765
787
  deleteFolder(id: string, requestId?: string): Promise<boolean>;
788
+ getGoals(args?: GetGoalsArgs): Promise<GetGoalsResponse>;
789
+ searchGoals(args: SearchGoalsArgs): Promise<GetGoalsResponse>;
790
+ getGoal(id: string): Promise<Goal>;
791
+ addGoal(args: AddGoalArgs, requestId?: string): Promise<Goal>;
792
+ updateGoal(id: string, args: UpdateGoalArgs, requestId?: string): Promise<Goal>;
793
+ deleteGoal(id: string, requestId?: string): Promise<boolean>;
794
+ completeGoal(id: string, requestId?: string): Promise<Goal>;
795
+ uncompleteGoal(id: string, requestId?: string): Promise<Goal>;
796
+ linkTaskToGoal(args: TaskLinkingArgs, requestId?: string): Promise<Goal>;
797
+ unlinkTaskFromGoal(args: TaskLinkingArgs, requestId?: string): Promise<boolean>;
766
798
  /**
767
799
  * Retrieves a list of available backups.
768
800
  *
@@ -845,7 +877,6 @@ export declare class TodoistApi {
845
877
  * @returns A promise that resolves to the import result.
846
878
  */
847
879
  importTemplateFromId(args: ImportTemplateFromIdArgs, requestId?: string): Promise<ImportTemplateResponse>;
848
- private validateTemplateResponse;
849
880
  /**
850
881
  * Gets pending invitations for a workspace.
851
882
  *
@@ -0,0 +1,27 @@
1
+ import type { CustomFetch } 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
+ };
15
+ /**
16
+ * Makes a request to the Sync API and handles error checking.
17
+ *
18
+ * @param ctx - HTTP identity (auth token, sync API base URI, optional custom fetch).
19
+ * @param syncRequest - The sync request payload.
20
+ * @param options - Optional request identifier and commands flag.
21
+ * @returns The sync response data.
22
+ * @throws TodoistRequestError if sync status contains errors.
23
+ */
24
+ export declare function performSyncRequest(ctx: SyncRequestContext, syncRequest: SyncRequest, options?: {
25
+ requestId?: string;
26
+ hasSyncCommands?: boolean;
27
+ }): Promise<SyncResponse>;
@@ -0,0 +1,2 @@
1
+ export * from './types.js';
2
+ export * from './requests.js';
@@ -0,0 +1,33 @@
1
+ import type { SearchArgs } from '../common.js';
2
+ import type { Workspace } from '../workspaces/index.js';
3
+ import type { Goal, GoalOwnerType } from './types.js';
4
+ export type GetGoalsArgs = {
5
+ ownerType?: GoalOwnerType;
6
+ workspaceId?: Workspace['id'];
7
+ cursor?: string | null;
8
+ limit?: number;
9
+ };
10
+ export type SearchGoalsArgs = SearchArgs & {
11
+ ownerType?: GoalOwnerType;
12
+ };
13
+ export type GetGoalsResponse = {
14
+ results: Goal[];
15
+ nextCursor: string | null;
16
+ };
17
+ export type AddGoalArgs = {
18
+ name: string;
19
+ workspaceId?: string;
20
+ description?: string | null;
21
+ deadline?: string | null;
22
+ responsibleUid?: string | null;
23
+ };
24
+ export type UpdateGoalArgs = {
25
+ name?: string;
26
+ description?: string | null;
27
+ deadline?: string | null;
28
+ responsibleUid?: string | null;
29
+ };
30
+ export type TaskLinkingArgs = {
31
+ goalId: string;
32
+ taskId: string;
33
+ };
@@ -0,0 +1,51 @@
1
+ import { z } from 'zod';
2
+ /** Available goal owner types. */
3
+ export declare const GOAL_OWNER_TYPES: readonly ["USER", "WORKSPACE"];
4
+ /** Goal owner type. */
5
+ export type GoalOwnerType = (typeof GOAL_OWNER_TYPES)[number];
6
+ /**
7
+ * Progress of a {@link Goal}.
8
+ *
9
+ * The REST API returns these counts under `total_item_count` / `completed_item_count`,
10
+ * reflecting the backend's generic "item" terminology. The SDK normalizes them to
11
+ * `totalTaskCount` / `completedTaskCount` so the public surface consistently speaks
12
+ * in "tasks" (matching the rest of the SDK). The `preprocess` step below performs
13
+ * that rename after the transport layer's snake_case → camelCase conversion — do not
14
+ * remove it without also changing the downstream field names.
15
+ */
16
+ export declare const GoalProgressSchema: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodObject<{
17
+ totalTaskCount: z.ZodNumber;
18
+ completedTaskCount: z.ZodNumber;
19
+ percentage: z.ZodNumber;
20
+ }, z.core.$loose>>;
21
+ export type GoalProgress = z.infer<typeof GoalProgressSchema>;
22
+ export declare const GoalSchema: z.ZodObject<{
23
+ id: z.ZodString;
24
+ ownerType: z.ZodEnum<{
25
+ USER: "USER";
26
+ WORKSPACE: "WORKSPACE";
27
+ }>;
28
+ ownerId: z.ZodString;
29
+ name: z.ZodString;
30
+ description: z.ZodNullable<z.ZodString>;
31
+ deadline: z.ZodNullable<z.ZodString>;
32
+ parentGoalId: z.ZodNullable<z.ZodString>;
33
+ childOrder: z.ZodNumber;
34
+ isCompleted: z.ZodBoolean;
35
+ completedAt: z.ZodNullable<z.ZodCoercedDate<unknown>>;
36
+ responsibleUid: z.ZodNullable<z.ZodString>;
37
+ isDeleted: z.ZodBoolean;
38
+ progress: z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodObject<{
39
+ totalTaskCount: z.ZodNumber;
40
+ completedTaskCount: z.ZodNumber;
41
+ percentage: z.ZodNumber;
42
+ }, z.core.$loose>>>;
43
+ creatorUid: z.ZodString;
44
+ createdAt: z.ZodCoercedDate<unknown>;
45
+ updatedAt: z.ZodCoercedDate<unknown>;
46
+ }, z.core.$loose>;
47
+ /**
48
+ * Represents a goal in Todoist.
49
+ * Goals support dual ownership: personal (ownerType=USER) and workspace (ownerType=WORKSPACE).
50
+ */
51
+ export type Goal = z.infer<typeof GoalSchema>;
@@ -83,3 +83,10 @@ export type CustomFetchResponse = {
83
83
  export type CustomFetch = (url: string, options?: RequestInit & {
84
84
  timeout?: number;
85
85
  }) => Promise<CustomFetchResponse>;
86
+ /**
87
+ * Response from a binary file endpoint (e.g. attachment view, backup download),
88
+ * extending CustomFetchResponse with `arrayBuffer()` support for binary content.
89
+ */
90
+ export type FileResponse = CustomFetchResponse & {
91
+ arrayBuffer(): Promise<ArrayBuffer>;
92
+ };
@@ -9,6 +9,7 @@ export * from './productivity/index.js';
9
9
  export * from './activity/index.js';
10
10
  export * from './workspaces/index.js';
11
11
  export * from './folders/index.js';
12
+ export * from './goals/index.js';
12
13
  export * from './insights/index.js';
13
14
  export * from './backups/index.js';
14
15
  export * from './id-mappings/index.js';
@@ -0,0 +1,33 @@
1
+ import type { GoalOwnerType } from '../../goals/types.js';
2
+ export type GoalAddArgs = {
3
+ ownerType: GoalOwnerType;
4
+ ownerId: string;
5
+ name: string;
6
+ description?: string | null;
7
+ deadline?: string | null;
8
+ responsibleUid?: string | null;
9
+ };
10
+ export type GoalUpdateArgs = {
11
+ id: string;
12
+ name?: string;
13
+ description?: string | null;
14
+ deadline?: string | null;
15
+ responsibleUid?: string | null;
16
+ };
17
+ export type GoalCompleteArgs = {
18
+ id: string;
19
+ };
20
+ export type GoalUncompleteArgs = {
21
+ id: string;
22
+ };
23
+ export type GoalDeleteArgs = {
24
+ id: string;
25
+ };
26
+ export type GoalLinkItemArgs = {
27
+ goalId: string;
28
+ itemId: string;
29
+ };
30
+ export type GoalUnlinkItemArgs = {
31
+ goalId: string;
32
+ itemId: string;
33
+ };
@@ -1,6 +1,7 @@
1
1
  import type { CalendarUpdateArgs, CalendarAccountUpdateArgs, CalendarAccountRestoreTaskCalendarArgs } from './calendars.js';
2
2
  import type { FilterAddArgs, FilterUpdateArgs, FilterUpdateOrdersArgs, FilterDeleteArgs } from './filters.js';
3
3
  import type { FolderAddArgs, FolderUpdateArgs, FolderDeleteArgs } from './folders.js';
4
+ import type { GoalAddArgs, GoalUpdateArgs, GoalCompleteArgs, GoalUncompleteArgs, GoalDeleteArgs, GoalLinkItemArgs, GoalUnlinkItemArgs } from './goals.js';
4
5
  import type { LabelAddArgs, LabelRenameArgs, LabelUpdateArgs, LabelUpdateOrdersArgs, LabelDeleteArgs, LabelDeleteOccurrencesArgs } from './labels.js';
5
6
  import type { NoteAddArgs, NoteUpdateArgs, NoteDeleteArgs, NoteReactionAddArgs, NoteReactionRemoveArgs } from './notes.js';
6
7
  import type { LiveNotificationsMarkUnreadArgs, LiveNotificationsMarkReadArgs, LiveNotificationsMarkReadAllArgs, LiveNotificationsSetLastReadArgs } from './notifications.js';
@@ -96,6 +97,13 @@ export type SyncCommandsMap = {
96
97
  workspace_goal_delete: WorkspaceGoalDeleteArgs;
97
98
  workspace_goal_project_add: WorkspaceGoalProjectAddArgs;
98
99
  workspace_goal_project_remove: WorkspaceGoalProjectRemoveArgs;
100
+ goal_add: GoalAddArgs;
101
+ goal_update: GoalUpdateArgs;
102
+ goal_complete: GoalCompleteArgs;
103
+ goal_uncomplete: GoalUncompleteArgs;
104
+ goal_delete: GoalDeleteArgs;
105
+ goal_link_item: GoalLinkItemArgs;
106
+ goal_unlink_item: GoalUnlinkItemArgs;
99
107
  live_notifications_mark_unread: LiveNotificationsMarkUnreadArgs;
100
108
  live_notifications_mark_read: LiveNotificationsMarkReadArgs;
101
109
  live_notifications_mark_read_all: LiveNotificationsMarkReadAllArgs;
@@ -163,6 +171,7 @@ export * from './workspaces.js';
163
171
  export * from './folders.js';
164
172
  export * from './workspace-filters.js';
165
173
  export * from './workspace-goals.js';
174
+ export * from './goals.js';
166
175
  export * from './notifications.js';
167
176
  export * from './sharing.js';
168
177
  export * from './view-options.js';
@@ -1,5 +1,5 @@
1
1
  /**
2
2
  * All available Sync API resource types.
3
3
  */
4
- export declare const SYNC_RESOURCE_TYPES: readonly ["labels", "projects", "items", "notes", "project_notes", "sections", "filters", "reminders", "reminders_location", "locations", "user", "live_notifications", "collaborators", "collaborator_states", "user_settings", "notification_settings", "user_plan_limits", "completed_info", "stats", "workspaces", "workspace_users", "workspace_filters", "view_options", "project_view_options_defaults", "role_actions", "folders", "workspace_goals", "day_orders", "calendars", "calendar_accounts", "suggestions", "tooltips"];
4
+ export declare const SYNC_RESOURCE_TYPES: readonly ["labels", "projects", "items", "notes", "project_notes", "sections", "filters", "reminders", "reminders_location", "locations", "user", "live_notifications", "collaborators", "collaborator_states", "user_settings", "notification_settings", "user_plan_limits", "completed_info", "stats", "workspaces", "workspace_users", "workspace_filters", "view_options", "project_view_options_defaults", "role_actions", "folders", "workspace_goals", "goals", "day_orders", "calendars", "calendar_accounts", "suggestions", "tooltips"];
5
5
  export type SyncResourceType = (typeof SYNC_RESOURCE_TYPES)[number];
@@ -32,6 +32,7 @@ export declare const GROUPED_BY_OPTIONS: readonly ["ASSIGNEE", "ADDED_DATE", "DU
32
32
  /** Field to group tasks by. */
33
33
  export type GroupedBy = (typeof GROUPED_BY_OPTIONS)[number];
34
34
  export declare const GroupedBySchema: z.ZodNullable<z.ZodEnum<{
35
+ WORKSPACE: "WORKSPACE";
35
36
  PROJECT: "PROJECT";
36
37
  LABEL: "LABEL";
37
38
  ASSIGNEE: "ASSIGNEE";
@@ -39,20 +40,19 @@ export declare const GroupedBySchema: z.ZodNullable<z.ZodEnum<{
39
40
  DUE_DATE: "DUE_DATE";
40
41
  DEADLINE: "DEADLINE";
41
42
  PRIORITY: "PRIORITY";
42
- WORKSPACE: "WORKSPACE";
43
43
  }>>;
44
44
  /** Available sorting options. */
45
45
  export declare const SORTED_BY_OPTIONS: readonly ["MANUAL", "ALPHABETICALLY", "ASSIGNEE", "DUE_DATE", "DEADLINE", "ADDED_DATE", "PRIORITY", "PROJECT", "WORKSPACE"];
46
46
  /** Field to sort tasks by. */
47
47
  export type SortedBy = (typeof SORTED_BY_OPTIONS)[number];
48
48
  export declare const SortedBySchema: z.ZodNullable<z.ZodEnum<{
49
+ WORKSPACE: "WORKSPACE";
49
50
  PROJECT: "PROJECT";
50
51
  ASSIGNEE: "ASSIGNEE";
51
52
  ADDED_DATE: "ADDED_DATE";
52
53
  DUE_DATE: "DUE_DATE";
53
54
  DEADLINE: "DEADLINE";
54
55
  PRIORITY: "PRIORITY";
55
- WORKSPACE: "WORKSPACE";
56
56
  MANUAL: "MANUAL";
57
57
  ALPHABETICALLY: "ALPHABETICALLY";
58
58
  }>>;
@@ -92,6 +92,7 @@ export declare const ViewOptionsSchema: z.ZodObject<{
92
92
  }>;
93
93
  objectId: z.ZodOptional<z.ZodString>;
94
94
  groupedBy: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
95
+ WORKSPACE: "WORKSPACE";
95
96
  PROJECT: "PROJECT";
96
97
  LABEL: "LABEL";
97
98
  ASSIGNEE: "ASSIGNEE";
@@ -99,7 +100,6 @@ export declare const ViewOptionsSchema: z.ZodObject<{
99
100
  DUE_DATE: "DUE_DATE";
100
101
  DEADLINE: "DEADLINE";
101
102
  PRIORITY: "PRIORITY";
102
- WORKSPACE: "WORKSPACE";
103
103
  }>>>;
104
104
  filteredBy: z.ZodOptional<z.ZodNullable<z.ZodString>>;
105
105
  viewMode: z.ZodOptional<z.ZodEnum<{
@@ -109,13 +109,13 @@ export declare const ViewOptionsSchema: z.ZodObject<{
109
109
  }>>;
110
110
  showCompletedTasks: z.ZodOptional<z.ZodBoolean>;
111
111
  sortedBy: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
112
+ WORKSPACE: "WORKSPACE";
112
113
  PROJECT: "PROJECT";
113
114
  ASSIGNEE: "ASSIGNEE";
114
115
  ADDED_DATE: "ADDED_DATE";
115
116
  DUE_DATE: "DUE_DATE";
116
117
  DEADLINE: "DEADLINE";
117
118
  PRIORITY: "PRIORITY";
118
- WORKSPACE: "WORKSPACE";
119
119
  MANUAL: "MANUAL";
120
120
  ALPHABETICALLY: "ALPHABETICALLY";
121
121
  }>>>;
@@ -133,6 +133,7 @@ export declare const ProjectViewOptionsDefaultsSchema: z.ZodObject<{
133
133
  CALENDAR: "CALENDAR";
134
134
  }>>>;
135
135
  groupedBy: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
136
+ WORKSPACE: "WORKSPACE";
136
137
  PROJECT: "PROJECT";
137
138
  LABEL: "LABEL";
138
139
  ASSIGNEE: "ASSIGNEE";
@@ -140,16 +141,15 @@ export declare const ProjectViewOptionsDefaultsSchema: z.ZodObject<{
140
141
  DUE_DATE: "DUE_DATE";
141
142
  DEADLINE: "DEADLINE";
142
143
  PRIORITY: "PRIORITY";
143
- WORKSPACE: "WORKSPACE";
144
144
  }>>>;
145
145
  sortedBy: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
146
+ WORKSPACE: "WORKSPACE";
146
147
  PROJECT: "PROJECT";
147
148
  ASSIGNEE: "ASSIGNEE";
148
149
  ADDED_DATE: "ADDED_DATE";
149
150
  DUE_DATE: "DUE_DATE";
150
151
  DEADLINE: "DEADLINE";
151
152
  PRIORITY: "PRIORITY";
152
- WORKSPACE: "WORKSPACE";
153
153
  MANUAL: "MANUAL";
154
154
  ALPHABETICALLY: "ALPHABETICALLY";
155
155
  }>>>;
@@ -750,6 +750,7 @@ export declare const SyncResponseSchema: z.ZodObject<{
750
750
  }>;
751
751
  objectId: z.ZodOptional<z.ZodString>;
752
752
  groupedBy: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
753
+ WORKSPACE: "WORKSPACE";
753
754
  PROJECT: "PROJECT";
754
755
  LABEL: "LABEL";
755
756
  ASSIGNEE: "ASSIGNEE";
@@ -757,7 +758,6 @@ export declare const SyncResponseSchema: z.ZodObject<{
757
758
  DUE_DATE: "DUE_DATE";
758
759
  DEADLINE: "DEADLINE";
759
760
  PRIORITY: "PRIORITY";
760
- WORKSPACE: "WORKSPACE";
761
761
  }>>>;
762
762
  filteredBy: z.ZodOptional<z.ZodNullable<z.ZodString>>;
763
763
  viewMode: z.ZodOptional<z.ZodEnum<{
@@ -767,13 +767,13 @@ export declare const SyncResponseSchema: z.ZodObject<{
767
767
  }>>;
768
768
  showCompletedTasks: z.ZodOptional<z.ZodBoolean>;
769
769
  sortedBy: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
770
+ WORKSPACE: "WORKSPACE";
770
771
  PROJECT: "PROJECT";
771
772
  ASSIGNEE: "ASSIGNEE";
772
773
  ADDED_DATE: "ADDED_DATE";
773
774
  DUE_DATE: "DUE_DATE";
774
775
  DEADLINE: "DEADLINE";
775
776
  PRIORITY: "PRIORITY";
776
- WORKSPACE: "WORKSPACE";
777
777
  MANUAL: "MANUAL";
778
778
  ALPHABETICALLY: "ALPHABETICALLY";
779
779
  }>>>;
@@ -790,6 +790,7 @@ export declare const SyncResponseSchema: z.ZodObject<{
790
790
  CALENDAR: "CALENDAR";
791
791
  }>>>;
792
792
  groupedBy: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
793
+ WORKSPACE: "WORKSPACE";
793
794
  PROJECT: "PROJECT";
794
795
  LABEL: "LABEL";
795
796
  ASSIGNEE: "ASSIGNEE";
@@ -797,16 +798,15 @@ export declare const SyncResponseSchema: z.ZodObject<{
797
798
  DUE_DATE: "DUE_DATE";
798
799
  DEADLINE: "DEADLINE";
799
800
  PRIORITY: "PRIORITY";
800
- WORKSPACE: "WORKSPACE";
801
801
  }>>>;
802
802
  sortedBy: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
803
+ WORKSPACE: "WORKSPACE";
803
804
  PROJECT: "PROJECT";
804
805
  ASSIGNEE: "ASSIGNEE";
805
806
  ADDED_DATE: "ADDED_DATE";
806
807
  DUE_DATE: "DUE_DATE";
807
808
  DEADLINE: "DEADLINE";
808
809
  PRIORITY: "PRIORITY";
809
- WORKSPACE: "WORKSPACE";
810
810
  MANUAL: "MANUAL";
811
811
  ALPHABETICALLY: "ALPHABETICALLY";
812
812
  }>>>;
@@ -832,6 +832,31 @@ export declare const SyncResponseSchema: z.ZodObject<{
832
832
  defaultOrder: z.ZodNumber;
833
833
  childOrder: z.ZodNumber;
834
834
  }, z.core.$loose>>>;
835
+ goals: z.ZodOptional<z.ZodArray<z.ZodObject<{
836
+ id: z.ZodString;
837
+ ownerType: z.ZodEnum<{
838
+ USER: "USER";
839
+ WORKSPACE: "WORKSPACE";
840
+ }>;
841
+ ownerId: z.ZodString;
842
+ name: z.ZodString;
843
+ description: z.ZodNullable<z.ZodString>;
844
+ deadline: z.ZodNullable<z.ZodString>;
845
+ parentGoalId: z.ZodNullable<z.ZodString>;
846
+ childOrder: z.ZodNumber;
847
+ isCompleted: z.ZodBoolean;
848
+ completedAt: z.ZodNullable<z.ZodCoercedDate<unknown>>;
849
+ responsibleUid: z.ZodNullable<z.ZodString>;
850
+ isDeleted: z.ZodBoolean;
851
+ progress: z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodObject<{
852
+ totalTaskCount: z.ZodNumber;
853
+ completedTaskCount: z.ZodNumber;
854
+ percentage: z.ZodNumber;
855
+ }, z.core.$loose>>>;
856
+ creatorUid: z.ZodString;
857
+ createdAt: z.ZodCoercedDate<unknown>;
858
+ updatedAt: z.ZodCoercedDate<unknown>;
859
+ }, z.core.$loose>>>;
835
860
  workspaceGoals: z.ZodOptional<z.ZodArray<z.ZodObject<{
836
861
  id: z.ZodString;
837
862
  workspaceId: z.ZodString;
@@ -36,6 +36,7 @@ export type GetTasksArgs = {
36
36
  parentId?: string;
37
37
  label?: string;
38
38
  ids?: string[];
39
+ goalId?: string;
39
40
  cursor?: string | null;
40
41
  limit?: number;
41
42
  };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Converts a native Fetch `Headers` object into a plain `Record<string, string>`.
3
+ * Used when wrapping a native `fetch` response into the SDK's `FileResponse`
4
+ * shape (which expects headers as a plain record for symmetry with
5
+ * `CustomFetchResponse`).
6
+ */
7
+ export declare function headersToRecord(headers: Headers): Record<string, string>;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Joins path segments using `/` separator.
3
+ * @param segments A list of **valid** path segments.
4
+ * @returns A joined path.
5
+ */
6
+ export declare function generatePath(...segments: string[]): string;
7
+ /**
8
+ * Returns `fn(value)` spread into an object if `value` is defined, otherwise an empty object.
9
+ *
10
+ * Used to conditionally include a property on a payload object without
11
+ * resorting to mutation or ternary-built object literals.
12
+ */
13
+ export declare function spreadIfDefined<T, V extends Record<string, unknown>>(value: T | undefined, fn: (v: T) => V): V | Record<string, never>;
@@ -816,6 +816,53 @@ export declare const validateFolder: (input: unknown) => {
816
816
  defaultOrder: number;
817
817
  childOrder: number;
818
818
  }[];
819
+ export declare const validateGoal: (input: unknown) => {
820
+ [x: string]: unknown;
821
+ id: string;
822
+ ownerType: "USER" | "WORKSPACE";
823
+ ownerId: string;
824
+ name: string;
825
+ description: string | null;
826
+ deadline: string | null;
827
+ parentGoalId: string | null;
828
+ childOrder: number;
829
+ isCompleted: boolean;
830
+ completedAt: Date | null;
831
+ responsibleUid: string | null;
832
+ isDeleted: boolean;
833
+ creatorUid: string;
834
+ createdAt: Date;
835
+ updatedAt: Date;
836
+ progress?: {
837
+ [x: string]: unknown;
838
+ totalTaskCount: number;
839
+ completedTaskCount: number;
840
+ percentage: number;
841
+ } | undefined;
842
+ }, validateGoalArray: (input: unknown) => {
843
+ [x: string]: unknown;
844
+ id: string;
845
+ ownerType: "USER" | "WORKSPACE";
846
+ ownerId: string;
847
+ name: string;
848
+ description: string | null;
849
+ deadline: string | null;
850
+ parentGoalId: string | null;
851
+ childOrder: number;
852
+ isCompleted: boolean;
853
+ completedAt: Date | null;
854
+ responsibleUid: string | null;
855
+ isDeleted: boolean;
856
+ creatorUid: string;
857
+ createdAt: Date;
858
+ updatedAt: Date;
859
+ progress?: {
860
+ [x: string]: unknown;
861
+ totalTaskCount: number;
862
+ completedTaskCount: number;
863
+ percentage: number;
864
+ } | undefined;
865
+ }[];
819
866
  export declare const validateNote: (input: unknown) => {
820
867
  [x: string]: unknown;
821
868
  id: string;
@@ -1137,29 +1184,29 @@ export declare const validateViewOptions: (input: unknown) => {
1137
1184
  [x: string]: unknown;
1138
1185
  viewType: "PROJECT" | "TODAY" | "UPCOMING" | "LABEL" | "FILTER" | "WORKSPACE_FILTER" | "SEARCH" | "TEMPLATE_PREVIEW" | "TASK_DETAIL" | "AUTOMATION" | "ASSIGNED" | "OVERDUE" | "WORKSPACE_OVERVIEW";
1139
1186
  objectId?: string | undefined;
1140
- groupedBy?: "PROJECT" | "LABEL" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | "WORKSPACE" | null | undefined;
1187
+ groupedBy?: "WORKSPACE" | "PROJECT" | "LABEL" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | null | undefined;
1141
1188
  filteredBy?: string | null | undefined;
1142
1189
  viewMode?: "LIST" | "BOARD" | "CALENDAR" | undefined;
1143
1190
  showCompletedTasks?: boolean | undefined;
1144
- sortedBy?: "PROJECT" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | "WORKSPACE" | "MANUAL" | "ALPHABETICALLY" | null | undefined;
1191
+ sortedBy?: "WORKSPACE" | "PROJECT" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | "MANUAL" | "ALPHABETICALLY" | null | undefined;
1145
1192
  sortOrder?: "ASC" | "DESC" | null | undefined;
1146
1193
  }, validateViewOptionsArray: (input: unknown) => {
1147
1194
  [x: string]: unknown;
1148
1195
  viewType: "PROJECT" | "TODAY" | "UPCOMING" | "LABEL" | "FILTER" | "WORKSPACE_FILTER" | "SEARCH" | "TEMPLATE_PREVIEW" | "TASK_DETAIL" | "AUTOMATION" | "ASSIGNED" | "OVERDUE" | "WORKSPACE_OVERVIEW";
1149
1196
  objectId?: string | undefined;
1150
- groupedBy?: "PROJECT" | "LABEL" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | "WORKSPACE" | null | undefined;
1197
+ groupedBy?: "WORKSPACE" | "PROJECT" | "LABEL" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | null | undefined;
1151
1198
  filteredBy?: string | null | undefined;
1152
1199
  viewMode?: "LIST" | "BOARD" | "CALENDAR" | undefined;
1153
1200
  showCompletedTasks?: boolean | undefined;
1154
- sortedBy?: "PROJECT" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | "WORKSPACE" | "MANUAL" | "ALPHABETICALLY" | null | undefined;
1201
+ sortedBy?: "WORKSPACE" | "PROJECT" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | "MANUAL" | "ALPHABETICALLY" | null | undefined;
1155
1202
  sortOrder?: "ASC" | "DESC" | null | undefined;
1156
1203
  }[];
1157
1204
  export declare const validateProjectViewOptionsDefaults: (input: unknown) => {
1158
1205
  [x: string]: unknown;
1159
1206
  projectId: string;
1160
1207
  viewMode?: "LIST" | "BOARD" | "CALENDAR" | null | undefined;
1161
- groupedBy?: "PROJECT" | "LABEL" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | "WORKSPACE" | null | undefined;
1162
- sortedBy?: "PROJECT" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | "WORKSPACE" | "MANUAL" | "ALPHABETICALLY" | null | undefined;
1208
+ groupedBy?: "WORKSPACE" | "PROJECT" | "LABEL" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | null | undefined;
1209
+ sortedBy?: "WORKSPACE" | "PROJECT" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | "MANUAL" | "ALPHABETICALLY" | null | undefined;
1163
1210
  sortOrder?: "ASC" | "DESC" | null | undefined;
1164
1211
  showCompletedTasks?: boolean | undefined;
1165
1212
  filteredBy?: string | null | undefined;
@@ -1171,8 +1218,8 @@ export declare const validateProjectViewOptionsDefaults: (input: unknown) => {
1171
1218
  [x: string]: unknown;
1172
1219
  projectId: string;
1173
1220
  viewMode?: "LIST" | "BOARD" | "CALENDAR" | null | undefined;
1174
- groupedBy?: "PROJECT" | "LABEL" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | "WORKSPACE" | null | undefined;
1175
- sortedBy?: "PROJECT" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | "WORKSPACE" | "MANUAL" | "ALPHABETICALLY" | null | undefined;
1221
+ groupedBy?: "WORKSPACE" | "PROJECT" | "LABEL" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | null | undefined;
1222
+ sortedBy?: "WORKSPACE" | "PROJECT" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | "MANUAL" | "ALPHABETICALLY" | null | undefined;
1176
1223
  sortOrder?: "ASC" | "DESC" | null | undefined;
1177
1224
  showCompletedTasks?: boolean | undefined;
1178
1225
  filteredBy?: string | null | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doist/todoist-sdk",
3
- "version": "9.0.0",
3
+ "version": "9.1.0-next.2",
4
4
  "description": "The official TypeScript SDK for the Todoist REST API.",
5
5
  "author": "Doist developers",
6
6
  "repository": "https://github.com/Doist/todoist-sdk-typescript",