@doist/todoist-sdk 14.0.2 → 14.2.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.
Files changed (32) hide show
  1. package/README.md +46 -1
  2. package/dist/cjs/clients/view-options-client.js +25 -0
  3. package/dist/cjs/index.js +2 -1
  4. package/dist/cjs/todoist-api.js +30 -0
  5. package/dist/cjs/transport/http-dispatcher.js +25 -0
  6. package/dist/cjs/types/sync/resources/view-options.js +13 -4
  7. package/dist/cjs/utils/index.js +2 -0
  8. package/dist/cjs/utils/multipart-upload.js +171 -57
  9. package/dist/cjs/utils/task-sorting.js +281 -0
  10. package/dist/cjs/utils/view-options.js +19 -0
  11. package/dist/esm/clients/view-options-client.js +21 -0
  12. package/dist/esm/index.js +1 -1
  13. package/dist/esm/todoist-api.js +30 -0
  14. package/dist/esm/transport/http-dispatcher.js +25 -0
  15. package/dist/esm/types/sync/resources/view-options.js +12 -3
  16. package/dist/esm/utils/index.js +2 -0
  17. package/dist/esm/utils/multipart-upload.js +171 -57
  18. package/dist/esm/utils/task-sorting.js +277 -0
  19. package/dist/esm/utils/view-options.js +15 -0
  20. package/dist/types/clients/view-options-client.d.ts +8 -0
  21. package/dist/types/index.d.ts +2 -1
  22. package/dist/types/todoist-api.d.ts +24 -1
  23. package/dist/types/transport/http-dispatcher.d.ts +26 -1
  24. package/dist/types/types/sync/commands/project-view-options.d.ts +1 -4
  25. package/dist/types/types/sync/commands/view-options.d.ts +2 -1
  26. package/dist/types/types/sync/resources/view-options.d.ts +37 -7
  27. package/dist/types/types/sync/response.d.ts +24 -5
  28. package/dist/types/utils/index.d.ts +2 -0
  29. package/dist/types/utils/task-sorting.d.ts +38 -0
  30. package/dist/types/utils/validators.d.ts +24 -6
  31. package/dist/types/utils/view-options.d.ts +11 -0
  32. package/package.json +2 -3
@@ -1,4 +1,4 @@
1
- import type { ViewType, ViewMode, GroupedBy, SortedBy, SortOrder } from '../resources/view-options.js';
1
+ import type { CalendarSettings, GroupedBy, SortedBy, SortOrder, ViewMode, ViewType } from '../resources/view-options.js';
2
2
  export type ViewOptionsSetArgs = {
3
3
  viewType: ViewType;
4
4
  objectId?: string;
@@ -8,6 +8,7 @@ export type ViewOptionsSetArgs = {
8
8
  showCompletedTasks?: boolean;
9
9
  sortedBy?: SortedBy | null;
10
10
  sortOrder?: SortOrder | null;
11
+ calendarSettings?: CalendarSettings | null;
11
12
  };
12
13
  export type ViewOptionsDeleteArgs = {
13
14
  viewType: ViewType;
@@ -68,12 +68,23 @@ export declare const SortOrderSchema: z.ZodNullable<z.ZodEnum<{
68
68
  export declare const CALENDAR_LAYOUTS: readonly ["WEEK", "MONTH"];
69
69
  /** Calendar layout mode. */
70
70
  export type CalendarLayout = (typeof CALENDAR_LAYOUTS)[number];
71
+ /** Available task color sources for calendar views. */
72
+ export declare const CALENDAR_COLORS: readonly ["PRIORITY", "LABEL", "PROJECT"];
73
+ /** Task color source for a calendar view. */
74
+ export type CalendarColor = (typeof CALENDAR_COLORS)[number];
71
75
  export declare const CalendarSettingsSchema: z.ZodObject<{
72
- layout: z.ZodOptional<z.ZodEnum<{
76
+ layout: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
73
77
  WEEK: "WEEK";
74
78
  MONTH: "MONTH";
75
- }>>;
79
+ }>>>;
80
+ visibleDayCount: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<3>, z.ZodLiteral<7>]>>>;
81
+ color: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
82
+ PROJECT: "PROJECT";
83
+ LABEL: "LABEL";
84
+ PRIORITY: "PRIORITY";
85
+ }>>>;
76
86
  }, z.core.$loose>;
87
+ export type CalendarSettings = z.infer<typeof CalendarSettingsSchema>;
77
88
  export declare const ViewOptionsSchema: z.ZodObject<{
78
89
  viewType: z.ZodEnum<{
79
90
  PROJECT: "PROJECT";
@@ -90,7 +101,7 @@ export declare const ViewOptionsSchema: z.ZodObject<{
90
101
  OVERDUE: "OVERDUE";
91
102
  WORKSPACE_OVERVIEW: "WORKSPACE_OVERVIEW";
92
103
  }>;
93
- objectId: z.ZodOptional<z.ZodString>;
104
+ objectId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
94
105
  groupedBy: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
95
106
  PROJECT: "PROJECT";
96
107
  LABEL: "LABEL";
@@ -102,11 +113,11 @@ export declare const ViewOptionsSchema: z.ZodObject<{
102
113
  WORKSPACE: "WORKSPACE";
103
114
  }>>>;
104
115
  filteredBy: z.ZodOptional<z.ZodNullable<z.ZodString>>;
105
- viewMode: z.ZodOptional<z.ZodEnum<{
116
+ viewMode: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
106
117
  LIST: "LIST";
107
118
  BOARD: "BOARD";
108
119
  CALENDAR: "CALENDAR";
109
- }>>;
120
+ }>>>;
110
121
  showCompletedTasks: z.ZodOptional<z.ZodBoolean>;
111
122
  sortedBy: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
112
123
  PROJECT: "PROJECT";
@@ -123,6 +134,19 @@ export declare const ViewOptionsSchema: z.ZodObject<{
123
134
  ASC: "ASC";
124
135
  DESC: "DESC";
125
136
  }>>>;
137
+ calendarSettings: z.ZodOptional<z.ZodNullable<z.ZodObject<{
138
+ layout: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
139
+ WEEK: "WEEK";
140
+ MONTH: "MONTH";
141
+ }>>>;
142
+ visibleDayCount: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<3>, z.ZodLiteral<7>]>>>;
143
+ color: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
144
+ PROJECT: "PROJECT";
145
+ LABEL: "LABEL";
146
+ PRIORITY: "PRIORITY";
147
+ }>>>;
148
+ }, z.core.$loose>>>;
149
+ isDeleted: z.ZodOptional<z.ZodBoolean>;
126
150
  }, z.core.$loose>;
127
151
  export type ViewOptions = z.infer<typeof ViewOptionsSchema>;
128
152
  export declare const ProjectViewOptionsDefaultsSchema: z.ZodObject<{
@@ -160,10 +184,16 @@ export declare const ProjectViewOptionsDefaultsSchema: z.ZodObject<{
160
184
  showCompletedTasks: z.ZodOptional<z.ZodBoolean>;
161
185
  filteredBy: z.ZodOptional<z.ZodNullable<z.ZodString>>;
162
186
  calendarSettings: z.ZodOptional<z.ZodNullable<z.ZodObject<{
163
- layout: z.ZodOptional<z.ZodEnum<{
187
+ layout: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
164
188
  WEEK: "WEEK";
165
189
  MONTH: "MONTH";
166
- }>>;
190
+ }>>>;
191
+ visibleDayCount: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<3>, z.ZodLiteral<7>]>>>;
192
+ color: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
193
+ PROJECT: "PROJECT";
194
+ LABEL: "LABEL";
195
+ PRIORITY: "PRIORITY";
196
+ }>>>;
167
197
  }, z.core.$loose>>>;
168
198
  }, z.core.$loose>;
169
199
  export type ProjectViewOptionsDefaults = z.infer<typeof ProjectViewOptionsDefaultsSchema>;
@@ -751,7 +751,7 @@ export declare const SyncResponseSchema: z.ZodObject<{
751
751
  OVERDUE: "OVERDUE";
752
752
  WORKSPACE_OVERVIEW: "WORKSPACE_OVERVIEW";
753
753
  }>;
754
- objectId: z.ZodOptional<z.ZodString>;
754
+ objectId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
755
755
  groupedBy: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
756
756
  PROJECT: "PROJECT";
757
757
  LABEL: "LABEL";
@@ -763,11 +763,11 @@ export declare const SyncResponseSchema: z.ZodObject<{
763
763
  WORKSPACE: "WORKSPACE";
764
764
  }>>>;
765
765
  filteredBy: z.ZodOptional<z.ZodNullable<z.ZodString>>;
766
- viewMode: z.ZodOptional<z.ZodEnum<{
766
+ viewMode: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
767
767
  LIST: "LIST";
768
768
  BOARD: "BOARD";
769
769
  CALENDAR: "CALENDAR";
770
- }>>;
770
+ }>>>;
771
771
  showCompletedTasks: z.ZodOptional<z.ZodBoolean>;
772
772
  sortedBy: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
773
773
  PROJECT: "PROJECT";
@@ -784,6 +784,19 @@ export declare const SyncResponseSchema: z.ZodObject<{
784
784
  ASC: "ASC";
785
785
  DESC: "DESC";
786
786
  }>>>;
787
+ calendarSettings: z.ZodOptional<z.ZodNullable<z.ZodObject<{
788
+ layout: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
789
+ WEEK: "WEEK";
790
+ MONTH: "MONTH";
791
+ }>>>;
792
+ visibleDayCount: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<3>, z.ZodLiteral<7>]>>>;
793
+ color: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
794
+ PROJECT: "PROJECT";
795
+ LABEL: "LABEL";
796
+ PRIORITY: "PRIORITY";
797
+ }>>>;
798
+ }, z.core.$loose>>>;
799
+ isDeleted: z.ZodOptional<z.ZodBoolean>;
787
800
  }, z.core.$loose>>>;
788
801
  projectViewOptionsDefaults: z.ZodOptional<z.ZodArray<z.ZodObject<{
789
802
  projectId: z.ZodString;
@@ -820,10 +833,16 @@ export declare const SyncResponseSchema: z.ZodObject<{
820
833
  showCompletedTasks: z.ZodOptional<z.ZodBoolean>;
821
834
  filteredBy: z.ZodOptional<z.ZodNullable<z.ZodString>>;
822
835
  calendarSettings: z.ZodOptional<z.ZodNullable<z.ZodObject<{
823
- layout: z.ZodOptional<z.ZodEnum<{
836
+ layout: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
824
837
  WEEK: "WEEK";
825
838
  MONTH: "MONTH";
826
- }>>;
839
+ }>>>;
840
+ visibleDayCount: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<3>, z.ZodLiteral<7>]>>>;
841
+ color: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
842
+ PROJECT: "PROJECT";
843
+ LABEL: "LABEL";
844
+ PRIORITY: "PRIORITY";
845
+ }>>>;
827
846
  }, z.core.$loose>>>;
828
847
  }, z.core.$loose>>>;
829
848
  roleActions: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
@@ -3,5 +3,7 @@ export * from './sanitization.js';
3
3
  export { getTaskUrl, getProjectUrl, getSectionUrl } from './url-helpers.js';
4
4
  export { createCommand } from './sync-helpers.js';
5
5
  export * from './project-helpers.js';
6
+ export * from './task-sorting.js';
7
+ export * from './view-options.js';
6
8
  export { parseWebhookPayload, verifyWebhookSignature } from './webhook-parser.js';
7
9
  export type { VerifyWebhookSignatureArgs } from './webhook-parser.js';
@@ -0,0 +1,38 @@
1
+ import type { SortOrder, SortedBy } from '../types/sync/index.js';
2
+ import type { Task } from '../types/tasks/index.js';
3
+ /** Todoist's default task-ordering hierarchies. */
4
+ export declare const DEFAULT_TASK_ORDERS: readonly ["PRIORITY_FIRST", "DATE_FIRST"];
5
+ /** Default hierarchy used when a view has no named sorting. */
6
+ export type DefaultTaskOrder = (typeof DEFAULT_TASK_ORDERS)[number];
7
+ export type TaskSortOptions = {
8
+ /** Saved or requested sort field. Null and MANUAL use defaultOrder. */
9
+ sortedBy?: SortedBy | null;
10
+ /** Saved or requested direction. Defaults by field when absent. */
11
+ sortOrder?: SortOrder | null;
12
+ /** Default hierarchy for this view or filter query. */
13
+ defaultOrder: DefaultTaskOrder;
14
+ };
15
+ export type TaskSortContext = {
16
+ /** Project ID to its visible order. */
17
+ projectOrder?: ReadonlyMap<string, number>;
18
+ /** Project ID to the visible order of its workspace bucket. */
19
+ workspaceOrder?: ReadonlyMap<string, number>;
20
+ /** Resolves the display name used for assignee sorting. */
21
+ assigneeName?: (task: Task) => string | null | undefined;
22
+ /** Account IANA timezone. Defaults to UTC for deterministic behavior. */
23
+ timezone?: string;
24
+ /** Locale used for text comparisons. Defaults to English. */
25
+ locale?: string | readonly string[];
26
+ };
27
+ /**
28
+ * Sorts the supplied tasks using Todoist view-ordering rules.
29
+ *
30
+ * The function performs no I/O and always returns a new array. Exact project,
31
+ * workspace, assignee, localized text, and due-time ordering requires the
32
+ * corresponding context. Callers must sort each independent view section or
33
+ * group separately and preserve any subtask structure they render.
34
+ *
35
+ * This function sorts only the tasks supplied to it. Fetch every page first
36
+ * when globally correct ordering is required for a paginated query.
37
+ */
38
+ export declare function sortTasks(tasks: readonly Task[], options: TaskSortOptions, context?: TaskSortContext): Task[];
@@ -1153,23 +1153,37 @@ export declare const validateCompletedInfo: (input: unknown) => {
1153
1153
  export declare const validateViewOptions: (input: unknown) => {
1154
1154
  [x: string]: unknown;
1155
1155
  viewType: "PROJECT" | "TODAY" | "UPCOMING" | "LABEL" | "FILTER" | "WORKSPACE_FILTER" | "SEARCH" | "TEMPLATE_PREVIEW" | "TASK_DETAIL" | "AUTOMATION" | "ASSIGNED" | "OVERDUE" | "WORKSPACE_OVERVIEW";
1156
- objectId?: string | undefined;
1156
+ objectId?: string | null | undefined;
1157
1157
  groupedBy?: "PROJECT" | "LABEL" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | "WORKSPACE" | null | undefined;
1158
1158
  filteredBy?: string | null | undefined;
1159
- viewMode?: "LIST" | "BOARD" | "CALENDAR" | undefined;
1159
+ viewMode?: "LIST" | "BOARD" | "CALENDAR" | null | undefined;
1160
1160
  showCompletedTasks?: boolean | undefined;
1161
1161
  sortedBy?: "PROJECT" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | "WORKSPACE" | "MANUAL" | "ALPHABETICALLY" | null | undefined;
1162
1162
  sortOrder?: "ASC" | "DESC" | null | undefined;
1163
+ calendarSettings?: {
1164
+ [x: string]: unknown;
1165
+ layout?: "WEEK" | "MONTH" | null | undefined;
1166
+ visibleDayCount?: 3 | 1 | 7 | null | undefined;
1167
+ color?: "PROJECT" | "LABEL" | "PRIORITY" | null | undefined;
1168
+ } | null | undefined;
1169
+ isDeleted?: boolean | undefined;
1163
1170
  }, validateViewOptionsArray: (input: unknown) => {
1164
1171
  [x: string]: unknown;
1165
1172
  viewType: "PROJECT" | "TODAY" | "UPCOMING" | "LABEL" | "FILTER" | "WORKSPACE_FILTER" | "SEARCH" | "TEMPLATE_PREVIEW" | "TASK_DETAIL" | "AUTOMATION" | "ASSIGNED" | "OVERDUE" | "WORKSPACE_OVERVIEW";
1166
- objectId?: string | undefined;
1173
+ objectId?: string | null | undefined;
1167
1174
  groupedBy?: "PROJECT" | "LABEL" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | "WORKSPACE" | null | undefined;
1168
1175
  filteredBy?: string | null | undefined;
1169
- viewMode?: "LIST" | "BOARD" | "CALENDAR" | undefined;
1176
+ viewMode?: "LIST" | "BOARD" | "CALENDAR" | null | undefined;
1170
1177
  showCompletedTasks?: boolean | undefined;
1171
1178
  sortedBy?: "PROJECT" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | "WORKSPACE" | "MANUAL" | "ALPHABETICALLY" | null | undefined;
1172
1179
  sortOrder?: "ASC" | "DESC" | null | undefined;
1180
+ calendarSettings?: {
1181
+ [x: string]: unknown;
1182
+ layout?: "WEEK" | "MONTH" | null | undefined;
1183
+ visibleDayCount?: 3 | 1 | 7 | null | undefined;
1184
+ color?: "PROJECT" | "LABEL" | "PRIORITY" | null | undefined;
1185
+ } | null | undefined;
1186
+ isDeleted?: boolean | undefined;
1173
1187
  }[];
1174
1188
  export declare const validateProjectViewOptionsDefaults: (input: unknown) => {
1175
1189
  [x: string]: unknown;
@@ -1182,7 +1196,9 @@ export declare const validateProjectViewOptionsDefaults: (input: unknown) => {
1182
1196
  filteredBy?: string | null | undefined;
1183
1197
  calendarSettings?: {
1184
1198
  [x: string]: unknown;
1185
- layout?: "WEEK" | "MONTH" | undefined;
1199
+ layout?: "WEEK" | "MONTH" | null | undefined;
1200
+ visibleDayCount?: 3 | 1 | 7 | null | undefined;
1201
+ color?: "PROJECT" | "LABEL" | "PRIORITY" | null | undefined;
1186
1202
  } | null | undefined;
1187
1203
  }, validateProjectViewOptionsDefaultsArray: (input: unknown) => {
1188
1204
  [x: string]: unknown;
@@ -1195,7 +1211,9 @@ export declare const validateProjectViewOptionsDefaults: (input: unknown) => {
1195
1211
  filteredBy?: string | null | undefined;
1196
1212
  calendarSettings?: {
1197
1213
  [x: string]: unknown;
1198
- layout?: "WEEK" | "MONTH" | undefined;
1214
+ layout?: "WEEK" | "MONTH" | null | undefined;
1215
+ visibleDayCount?: 3 | 1 | 7 | null | undefined;
1216
+ color?: "PROJECT" | "LABEL" | "PRIORITY" | null | undefined;
1199
1217
  } | null | undefined;
1200
1218
  }[];
1201
1219
  export declare const validateUserPlanLimits: (input: unknown) => {
@@ -0,0 +1,11 @@
1
+ import type { ViewOptions, ViewType } from '../types/sync/index.js';
2
+ export type FindViewOptionsArgs = {
3
+ /** View types that identify the logical view. */
4
+ viewTypes: readonly ViewType[];
5
+ /** Object ID for object-backed views. Omit for singleton views. */
6
+ objectId?: string | null;
7
+ };
8
+ /** Returns whether saved view options are active rather than a deletion tombstone. */
9
+ export declare function isActiveViewOption(options: ViewOptions): boolean;
10
+ /** Finds the active saved options for one logical view. */
11
+ export declare function findViewOptions(options: readonly ViewOptions[], args: FindViewOptionsArgs): ViewOptions | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doist/todoist-sdk",
3
- "version": "14.0.2",
3
+ "version": "14.2.0",
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",
@@ -53,9 +53,8 @@
53
53
  "dependencies": {
54
54
  "camelcase": "6.3.0",
55
55
  "emoji-regex": "10.6.0",
56
- "form-data": "4.0.6",
57
56
  "ts-custom-error": "^3.2.0",
58
- "undici": "7.24.8",
57
+ "undici": "^7.29.0",
59
58
  "uuid": "11.1.1",
60
59
  "zod": "4.3.6"
61
60
  },