@doist/todoist-api-typescript 7.5.0 → 7.6.1

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 (171) hide show
  1. package/dist/cjs/authentication.js +46 -2
  2. package/dist/cjs/consts/endpoints.js +54 -2
  3. package/dist/cjs/todoist-api.js +524 -6
  4. package/dist/cjs/types/activity/index.js +18 -0
  5. package/dist/cjs/types/activity/requests.js +2 -0
  6. package/dist/cjs/types/activity/types.js +28 -0
  7. package/dist/cjs/types/backups/index.js +18 -0
  8. package/dist/cjs/types/backups/requests.js +2 -0
  9. package/dist/cjs/types/backups/types.js +8 -0
  10. package/dist/cjs/types/comments/index.js +18 -0
  11. package/dist/cjs/types/comments/requests.js +2 -0
  12. package/dist/cjs/types/comments/types.js +60 -0
  13. package/dist/cjs/types/common.js +2 -0
  14. package/dist/cjs/types/emails/index.js +17 -0
  15. package/dist/cjs/types/emails/requests.js +5 -0
  16. package/dist/cjs/types/id-mappings/index.js +18 -0
  17. package/dist/cjs/types/id-mappings/requests.js +20 -0
  18. package/dist/cjs/types/id-mappings/types.js +12 -0
  19. package/dist/cjs/types/index.js +16 -2
  20. package/dist/cjs/types/insights/index.js +18 -0
  21. package/dist/cjs/types/insights/requests.js +2 -0
  22. package/dist/cjs/types/insights/types.js +84 -0
  23. package/dist/cjs/types/labels/index.js +18 -0
  24. package/dist/cjs/types/labels/requests.js +2 -0
  25. package/dist/cjs/types/labels/types.js +11 -0
  26. package/dist/cjs/types/productivity/index.js +17 -0
  27. package/dist/cjs/types/productivity/types.js +67 -0
  28. package/dist/cjs/types/projects/index.js +18 -0
  29. package/dist/cjs/types/projects/requests.js +2 -0
  30. package/dist/cjs/types/projects/types.js +56 -0
  31. package/dist/cjs/types/reminders/index.js +17 -0
  32. package/dist/cjs/types/sections/index.js +18 -0
  33. package/dist/cjs/types/sections/requests.js +2 -0
  34. package/dist/cjs/types/sections/types.js +22 -0
  35. package/dist/cjs/types/sync/commands/shared.js +2 -2
  36. package/dist/cjs/types/sync/resources/collaborators.js +2 -2
  37. package/dist/cjs/types/sync/resources/notes.js +2 -2
  38. package/dist/cjs/types/sync/resources/reminders.js +3 -3
  39. package/dist/cjs/types/sync/resources/user.js +2 -2
  40. package/dist/cjs/types/sync/resources/workspaces.js +5 -5
  41. package/dist/cjs/types/tasks/index.js +18 -0
  42. package/dist/cjs/types/tasks/requests.js +2 -0
  43. package/dist/cjs/types/tasks/types.js +59 -0
  44. package/dist/cjs/types/templates/index.js +17 -0
  45. package/dist/cjs/types/templates/requests.js +2 -0
  46. package/dist/cjs/types/uploads/index.js +17 -0
  47. package/dist/cjs/types/uploads/requests.js +2 -0
  48. package/dist/cjs/types/users/index.js +17 -0
  49. package/dist/cjs/types/users/types.js +51 -0
  50. package/dist/cjs/types/workspaces/index.js +18 -0
  51. package/dist/cjs/types/workspaces/requests.js +2 -0
  52. package/dist/cjs/types/workspaces/types.js +137 -0
  53. package/dist/cjs/utils/validators.js +47 -19
  54. package/dist/esm/authentication.js +46 -3
  55. package/dist/esm/consts/endpoints.js +43 -0
  56. package/dist/esm/todoist-api.js +522 -4
  57. package/dist/esm/types/activity/index.js +2 -0
  58. package/dist/esm/types/activity/requests.js +1 -0
  59. package/dist/esm/types/activity/types.js +25 -0
  60. package/dist/esm/types/backups/index.js +2 -0
  61. package/dist/esm/types/backups/requests.js +1 -0
  62. package/dist/esm/types/backups/types.js +5 -0
  63. package/dist/esm/types/comments/index.js +2 -0
  64. package/dist/esm/types/comments/requests.js +1 -0
  65. package/dist/esm/types/comments/types.js +57 -0
  66. package/dist/esm/types/common.js +1 -0
  67. package/dist/esm/types/emails/index.js +1 -0
  68. package/dist/esm/types/emails/requests.js +2 -0
  69. package/dist/esm/types/id-mappings/index.js +2 -0
  70. package/dist/esm/types/id-mappings/requests.js +17 -0
  71. package/dist/esm/types/id-mappings/types.js +9 -0
  72. package/dist/esm/types/index.js +16 -2
  73. package/dist/esm/types/insights/index.js +2 -0
  74. package/dist/esm/types/insights/requests.js +1 -0
  75. package/dist/esm/types/insights/types.js +81 -0
  76. package/dist/esm/types/labels/index.js +2 -0
  77. package/dist/esm/types/labels/requests.js +1 -0
  78. package/dist/esm/types/labels/types.js +8 -0
  79. package/dist/esm/types/productivity/index.js +1 -0
  80. package/dist/esm/types/productivity/types.js +64 -0
  81. package/dist/esm/types/projects/index.js +2 -0
  82. package/dist/esm/types/projects/requests.js +1 -0
  83. package/dist/esm/types/projects/types.js +53 -0
  84. package/dist/esm/types/reminders/index.js +1 -0
  85. package/dist/esm/types/sections/index.js +2 -0
  86. package/dist/esm/types/sections/requests.js +1 -0
  87. package/dist/esm/types/sections/types.js +19 -0
  88. package/dist/esm/types/sync/commands/shared.js +1 -1
  89. package/dist/esm/types/sync/resources/collaborators.js +1 -1
  90. package/dist/esm/types/sync/resources/notes.js +1 -1
  91. package/dist/esm/types/sync/resources/reminders.js +1 -1
  92. package/dist/esm/types/sync/resources/user.js +1 -1
  93. package/dist/esm/types/sync/resources/workspaces.js +1 -1
  94. package/dist/esm/types/tasks/index.js +2 -0
  95. package/dist/esm/types/tasks/requests.js +1 -0
  96. package/dist/esm/types/tasks/types.js +56 -0
  97. package/dist/esm/types/templates/index.js +1 -0
  98. package/dist/esm/types/templates/requests.js +1 -0
  99. package/dist/esm/types/uploads/index.js +1 -0
  100. package/dist/esm/types/uploads/requests.js +1 -0
  101. package/dist/esm/types/users/index.js +1 -0
  102. package/dist/esm/types/users/types.js +48 -0
  103. package/dist/esm/types/workspaces/index.js +2 -0
  104. package/dist/esm/types/workspaces/requests.js +1 -0
  105. package/dist/esm/types/workspaces/types.js +134 -0
  106. package/dist/esm/utils/validators.js +30 -2
  107. package/dist/types/authentication.d.ts +51 -6
  108. package/dist/types/consts/endpoints.d.ts +22 -0
  109. package/dist/types/test-utils/test-defaults.d.ts +5 -5
  110. package/dist/types/todoist-api.d.ts +209 -4
  111. package/dist/types/types/activity/index.d.ts +2 -0
  112. package/dist/types/types/activity/requests.d.ts +85 -0
  113. package/dist/types/types/activity/types.d.ts +49 -0
  114. package/dist/types/types/backups/index.d.ts +2 -0
  115. package/dist/types/types/backups/requests.d.ts +16 -0
  116. package/dist/types/types/backups/types.d.ts +7 -0
  117. package/dist/types/types/comments/index.d.ts +2 -0
  118. package/dist/types/types/comments/requests.d.ts +63 -0
  119. package/dist/types/types/comments/types.d.ts +141 -0
  120. package/dist/types/types/common.d.ts +6 -0
  121. package/dist/types/types/emails/index.d.ts +1 -0
  122. package/dist/types/types/emails/requests.d.ts +30 -0
  123. package/dist/types/types/id-mappings/index.d.ts +2 -0
  124. package/dist/types/types/id-mappings/requests.d.ts +28 -0
  125. package/dist/types/types/id-mappings/types.d.ts +13 -0
  126. package/dist/types/types/index.d.ts +16 -2
  127. package/dist/types/types/insights/index.d.ts +2 -0
  128. package/dist/types/types/insights/requests.d.ts +26 -0
  129. package/dist/types/types/insights/types.d.ts +186 -0
  130. package/dist/types/types/labels/index.d.ts +2 -0
  131. package/dist/types/types/labels/requests.d.ts +75 -0
  132. package/dist/types/types/labels/types.d.ts +13 -0
  133. package/dist/types/types/productivity/index.d.ts +1 -0
  134. package/dist/types/types/productivity/types.d.ts +115 -0
  135. package/dist/types/types/projects/index.d.ts +2 -0
  136. package/dist/types/types/projects/requests.d.ts +169 -0
  137. package/dist/types/types/projects/types.d.ts +201 -0
  138. package/dist/types/types/reminders/index.d.ts +1 -0
  139. package/dist/types/types/reminders/requests.d.ts +91 -0
  140. package/dist/types/types/sections/index.d.ts +2 -0
  141. package/dist/types/types/sections/requests.d.ts +41 -0
  142. package/dist/types/types/sections/types.d.ts +44 -0
  143. package/dist/types/types/sync/commands/projects.d.ts +2 -1
  144. package/dist/types/types/sync/commands/shared.d.ts +2 -2
  145. package/dist/types/types/sync/commands/workspaces.d.ts +1 -1
  146. package/dist/types/types/sync/resources/notes.d.ts +1 -1
  147. package/dist/types/types/sync/resources/user.d.ts +2 -2
  148. package/dist/types/types/sync/resources/view-options.d.ts +5 -5
  149. package/dist/types/types/sync/response.d.ts +5 -1
  150. package/dist/types/types/sync/user-preferences.d.ts +1 -1
  151. package/dist/types/types/tasks/index.d.ts +2 -0
  152. package/dist/types/types/tasks/requests.d.ts +197 -0
  153. package/dist/types/types/tasks/types.d.ts +162 -0
  154. package/dist/types/types/templates/index.d.ts +1 -0
  155. package/dist/types/types/templates/requests.d.ts +92 -0
  156. package/dist/types/types/uploads/index.d.ts +1 -0
  157. package/dist/types/types/uploads/requests.d.ts +32 -0
  158. package/dist/types/types/users/index.d.ts +1 -0
  159. package/dist/types/types/users/types.d.ts +66 -0
  160. package/dist/types/types/workspaces/index.d.ts +2 -0
  161. package/dist/types/types/workspaces/requests.d.ts +260 -0
  162. package/dist/types/types/workspaces/types.d.ts +225 -0
  163. package/dist/types/utils/colors.d.ts +1 -1
  164. package/dist/types/utils/validators.d.ts +205 -12
  165. package/package.json +1 -1
  166. package/dist/cjs/types/entities.js +0 -437
  167. package/dist/esm/types/entities.js +0 -434
  168. package/dist/types/types/entities.d.ts +0 -971
  169. package/dist/types/types/requests.d.ts +0 -856
  170. /package/dist/cjs/types/{requests.js → reminders/requests.js} +0 -0
  171. /package/dist/esm/types/{requests.js → reminders/requests.js} +0 -0
@@ -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.string(),
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 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export * from './requests.js';
@@ -0,0 +1,2 @@
1
+ /** Object types that support email forwarding. */
2
+ export const EMAIL_OBJECT_TYPES = ['project', 'project_comments', 'task'];
@@ -0,0 +1,2 @@
1
+ export * from './types.js';
2
+ export * from './requests.js';
@@ -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,9 @@
1
+ import { z } from 'zod';
2
+ export const IdMappingSchema = z.object({
3
+ oldId: z.string().nullable(),
4
+ newId: z.string().nullable(),
5
+ });
6
+ export const MovedIdSchema = z.object({
7
+ oldId: z.string(),
8
+ newId: z.string(),
9
+ });
@@ -1,5 +1,19 @@
1
- export * from './entities.js';
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 './insights/index.js';
12
+ export * from './backups/index.js';
13
+ export * from './id-mappings/index.js';
14
+ export * from './emails/index.js';
15
+ export * from './uploads/index.js';
16
+ export * from './templates/index.js';
2
17
  export * from './errors.js';
3
- export * from './requests.js';
4
18
  export * from './http.js';
5
19
  export * from './sync/index.js';
@@ -0,0 +1,2 @@
1
+ export * from './types.js';
2
+ export * from './requests.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,81 @@
1
+ import { z } from 'zod';
2
+ export const DayActivitySchema = z.object({
3
+ date: z.string(),
4
+ totalCount: z.number().int(),
5
+ });
6
+ export const WeekRollupSchema = z.object({
7
+ fromDate: z.string(),
8
+ toDate: z.string(),
9
+ totalCount: z.number().int(),
10
+ });
11
+ export const ProjectActivityStatsSchema = z.object({
12
+ dayItems: z.array(DayActivitySchema),
13
+ weekItems: z.array(WeekRollupSchema).nullable(),
14
+ });
15
+ /** Available project health statuses. */
16
+ export const HEALTH_STATUSES = [
17
+ 'UNKNOWN',
18
+ 'ON_TRACK',
19
+ 'AT_RISK',
20
+ 'CRITICAL',
21
+ 'EXCELLENT',
22
+ 'ERROR',
23
+ ];
24
+ export const TaskRecommendationSchema = z.object({
25
+ taskId: z.string(),
26
+ recommendation: z.string(),
27
+ });
28
+ export const ProjectHealthSchema = z.object({
29
+ status: z.enum(HEALTH_STATUSES),
30
+ description: z.string().nullable().optional(),
31
+ descriptionSummary: z.string().nullable().optional(),
32
+ taskRecommendations: z.array(TaskRecommendationSchema).nullable().optional(),
33
+ projectId: z.string().nullable().optional(),
34
+ updatedAt: z.string().nullable().optional(),
35
+ isStale: z.boolean().default(false),
36
+ updateInProgress: z.boolean().default(false),
37
+ });
38
+ export const ProjectMetricsSchema = z.object({
39
+ totalTasks: z.number().int(),
40
+ completedTasks: z.number().int(),
41
+ overdueTasks: z.number().int(),
42
+ tasksCreatedThisWeek: z.number().int(),
43
+ tasksCompletedThisWeek: z.number().int(),
44
+ averageCompletionTime: z.number().nullable(),
45
+ });
46
+ export const TaskContextSchema = z.object({
47
+ id: z.string(),
48
+ content: z.string(),
49
+ due: z.string().nullable().optional(),
50
+ deadline: z.string().nullable().optional(),
51
+ priority: z.string(),
52
+ isCompleted: z.boolean(),
53
+ createdAt: z.string(),
54
+ updatedAt: z.string(),
55
+ completedAt: z.string().nullable(),
56
+ completedByUid: z.string().nullable(),
57
+ labels: z.array(z.string()),
58
+ });
59
+ export const ProjectHealthContextSchema = z.object({
60
+ projectId: z.string(),
61
+ projectName: z.string(),
62
+ projectDescription: z.string().nullable(),
63
+ projectMetrics: ProjectMetricsSchema,
64
+ tasks: z.array(TaskContextSchema),
65
+ language: z.string().nullable().optional(),
66
+ });
67
+ export const ProjectProgressSchema = z.object({
68
+ projectId: z.string(),
69
+ completedCount: z.number().int(),
70
+ activeCount: z.number().int(),
71
+ progressPercent: z.number().int(),
72
+ });
73
+ export const ProjectInsightSchema = z.object({
74
+ projectId: z.string(),
75
+ health: ProjectHealthSchema.nullable(),
76
+ progress: ProjectProgressSchema.nullable(),
77
+ });
78
+ export const WorkspaceInsightsSchema = z.object({
79
+ folderId: z.string().nullable(),
80
+ projectInsights: z.array(ProjectInsightSchema),
81
+ });
@@ -0,0 +1,2 @@
1
+ export * from './types.js';
2
+ export * from './requests.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import { z } from 'zod';
2
+ export const LabelSchema = z.object({
3
+ id: z.string(),
4
+ order: z.number().int().nullable(),
5
+ name: z.string(),
6
+ color: z.string(),
7
+ isFavorite: z.boolean(),
8
+ });
@@ -0,0 +1 @@
1
+ export * from './types.js';
@@ -0,0 +1,64 @@
1
+ import { z } from 'zod';
2
+ export const StreakSchema = z.object({
3
+ count: z.number(),
4
+ start: z.string(),
5
+ end: z.string(),
6
+ });
7
+ export const CompletedItemSchema = z.object({
8
+ id: z.string(),
9
+ completed: z.number(),
10
+ });
11
+ export const ItemsWithDateSchema = z.object({
12
+ items: z.array(CompletedItemSchema),
13
+ totalCompleted: z.number(),
14
+ });
15
+ export const KarmaUpdateSchema = z.object({
16
+ time: z.string(),
17
+ newKarma: z.number(),
18
+ positiveKarma: z.number(),
19
+ negativeKarma: z.number(),
20
+ positiveKarmaReasons: z.array(z.any()),
21
+ negativeKarmaReasons: z.array(z.any()),
22
+ });
23
+ export const ProductivityStatsSchema = z.object({
24
+ completedCount: z.number(),
25
+ daysItems: z.array(ItemsWithDateSchema.extend({
26
+ date: z.string(),
27
+ })),
28
+ goals: z.object({
29
+ currentDailyStreak: StreakSchema,
30
+ currentWeeklyStreak: StreakSchema,
31
+ dailyGoal: z.number(),
32
+ ignoreDays: z.array(z.number()),
33
+ karmaDisabled: z.number(),
34
+ lastDailyStreak: StreakSchema,
35
+ lastWeeklyStreak: StreakSchema,
36
+ maxDailyStreak: StreakSchema,
37
+ maxWeeklyStreak: StreakSchema,
38
+ user: z.string(),
39
+ userId: z.string(),
40
+ vacationMode: z.number(),
41
+ weeklyGoal: z.number(),
42
+ }),
43
+ karma: z.number(),
44
+ karmaGraphData: z.array(z.object({
45
+ date: z.string(),
46
+ karmaAvg: z.number(),
47
+ })),
48
+ karmaLastUpdate: z.number(),
49
+ karmaTrend: z.string(),
50
+ karmaUpdateReasons: z.array(KarmaUpdateSchema),
51
+ projectColors: z.record(z.string(), z.string()),
52
+ weekItems: z.array(ItemsWithDateSchema.extend({
53
+ from: z.string(),
54
+ to: z.string(),
55
+ })),
56
+ });
57
+ export const ColorSchema = z.object({
58
+ /** The key of the color (i.e. 'berry_red') */
59
+ key: z.string(),
60
+ /** The display name of the color (i.e. 'Berry Red') */
61
+ displayName: z.string(),
62
+ /** The hex value of the color (i.e. '#b8255f') */
63
+ hexValue: z.string(),
64
+ });
@@ -0,0 +1,2 @@
1
+ export * from './types.js';
2
+ export * from './requests.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,53 @@
1
+ import { z } from 'zod';
2
+ import { getProjectUrl } from '../../utils/url-helpers.js';
3
+ /**
4
+ * Base schema for all project types in Todoist.
5
+ * Contains common fields shared between personal and workspace projects.
6
+ */
7
+ export const BaseProjectSchema = z.object({
8
+ id: z.string(),
9
+ canAssignTasks: z.boolean(),
10
+ childOrder: z.number().int(),
11
+ color: z.string(),
12
+ createdAt: z.string().nullable(),
13
+ isArchived: z.boolean(),
14
+ isDeleted: z.boolean(),
15
+ isFavorite: z.boolean(),
16
+ isFrozen: z.boolean(),
17
+ name: z.string(),
18
+ updatedAt: z.string().nullable(),
19
+ viewStyle: z.string(),
20
+ defaultOrder: z.number().int(),
21
+ description: z.string(),
22
+ isCollapsed: z.boolean(),
23
+ isShared: z.boolean(),
24
+ });
25
+ /**
26
+ * Schema for personal projects in Todoist.
27
+ */
28
+ export const PersonalProjectSchema = BaseProjectSchema.extend({
29
+ parentId: z.string().nullable(),
30
+ inboxProject: z.boolean().optional().default(false),
31
+ }).transform((data) => {
32
+ return Object.assign(Object.assign({}, data), { url: getProjectUrl(data.id, data.name) });
33
+ });
34
+ /** Available project visibility levels. */
35
+ export const PROJECT_VISIBILITIES = ['restricted', 'team', 'public'];
36
+ export const ProjectVisibilitySchema = z.enum(PROJECT_VISIBILITIES);
37
+ /**
38
+ * Schema for workspace projects in Todoist.
39
+ */
40
+ export const WorkspaceProjectSchema = BaseProjectSchema.extend({
41
+ access: z.object({ visibility: ProjectVisibilitySchema }).optional(),
42
+ collaboratorRoleDefault: z.string(),
43
+ folderId: z.string().nullable(),
44
+ isInviteOnly: z.boolean().nullable(),
45
+ isLinkSharingEnabled: z.boolean(),
46
+ role: z.string().nullable(),
47
+ status: z.string(),
48
+ workspaceId: z.string(),
49
+ }).transform((data) => {
50
+ return Object.assign(Object.assign({}, data), { url: getProjectUrl(data.id, data.name) });
51
+ });
52
+ /** Available project view styles. */
53
+ export const PROJECT_VIEW_STYLES = ['list', 'board', 'calendar'];
@@ -0,0 +1 @@
1
+ export * from './requests.js';
@@ -0,0 +1,2 @@
1
+ export * from './types.js';
2
+ export * from './requests.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,19 @@
1
+ import { z } from 'zod';
2
+ import { getSectionUrl } from '../../utils/url-helpers.js';
3
+ export const SectionSchema = z
4
+ .object({
5
+ id: z.string(),
6
+ userId: z.string(),
7
+ projectId: z.string(),
8
+ addedAt: z.string(),
9
+ updatedAt: z.string(),
10
+ archivedAt: z.string().nullable(),
11
+ name: z.string(),
12
+ sectionOrder: z.number().int(),
13
+ isArchived: z.boolean(),
14
+ isDeleted: z.boolean(),
15
+ isCollapsed: z.boolean(),
16
+ })
17
+ .transform((data) => {
18
+ return Object.assign(Object.assign({}, data), { url: getSectionUrl(data.id, data.name) });
19
+ });
@@ -9,7 +9,7 @@ export const PROJECT_STATUSES = [
9
9
  'COMPLETED',
10
10
  'CANCELED',
11
11
  ];
12
- export { COLLABORATOR_ROLES } from '../../entities.js';
12
+ export { COLLABORATOR_ROLES } from '../../workspaces/types.js';
13
13
  /** Available reminder notification services. */
14
14
  export const REMINDER_SERVICES = ['default', 'email', 'mobile', 'push', 'no_default'];
15
15
  /** Available workspace project sort orders. */
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { WorkspaceRoleSchema } from '../../entities.js';
2
+ import { WorkspaceRoleSchema } from '../../workspaces/types.js';
3
3
  export const CollaboratorSchema = z
4
4
  .object({
5
5
  id: z.string(),
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { AttachmentSchema } from '../../entities.js';
2
+ import { AttachmentSchema } from '../../comments/types.js';
3
3
  /**
4
4
  * Sync API note (comment) resource.
5
5
  * Separate from the REST `CommentSchema` which transforms `itemId` to `taskId`.
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { DueDateSchema } from '../../entities.js';
2
+ import { DueDateSchema } from '../../tasks/types.js';
3
3
  export const ReminderBaseSchema = z.object({
4
4
  id: z.string(),
5
5
  notifyUid: z.string(),
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { PREMIUM_STATUSES } from '../../entities.js';
2
+ import { PREMIUM_STATUSES } from '../../users/types.js';
3
3
  import { BooleanFromZeroOneSchema, DateFormatSchema, DayOfWeekSchema, TimeFormatSchema, } from '../user-preferences.js';
4
4
  export const FeaturesSchema = z
5
5
  .object({
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { WorkspaceRoleSchema, WorkspacePlanSchema, WorkspaceLimitsSchema, WorkspacePropertiesSchema, } from '../../entities.js';
2
+ import { WorkspaceRoleSchema, WorkspacePlanSchema, WorkspaceLimitsSchema, WorkspacePropertiesSchema, } from '../../workspaces/types.js';
3
3
  /**
4
4
  * Sync API workspace resource.
5
5
  *
@@ -0,0 +1,2 @@
1
+ export * from './types.js';
2
+ export * from './requests.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,56 @@
1
+ import { z } from 'zod';
2
+ import { getTaskUrl } from '../../utils/url-helpers.js';
3
+ import { hasUncompletablePrefix } from '../../utils/uncompletable-helpers.js';
4
+ export const DueDateSchema = z
5
+ .object({
6
+ isRecurring: z.boolean(),
7
+ string: z.string(),
8
+ date: z.string(),
9
+ })
10
+ .extend({
11
+ datetime: z.string().nullable().optional(),
12
+ timezone: z.string().nullable().optional(),
13
+ lang: z.string().nullable().optional(),
14
+ });
15
+ /** Available duration units for task deadlines. */
16
+ export const DURATION_UNITS = ['minute', 'day'];
17
+ export const DurationSchema = z.object({
18
+ amount: z.number().positive('Value should be greater than zero'),
19
+ unit: z.enum(DURATION_UNITS),
20
+ });
21
+ export const DeadlineSchema = z.object({
22
+ date: z.string(),
23
+ lang: z.string(),
24
+ });
25
+ export const TaskSchema = z
26
+ .object({
27
+ id: z.string(),
28
+ userId: z.string(),
29
+ projectId: z.string(),
30
+ sectionId: z.string().nullable(),
31
+ parentId: z.string().nullable(),
32
+ addedByUid: z.string().nullable(),
33
+ assignedByUid: z.string().nullable(),
34
+ responsibleUid: z.string().nullable(),
35
+ labels: z.array(z.string()),
36
+ deadline: DeadlineSchema.nullable(),
37
+ duration: DurationSchema.nullable(),
38
+ checked: z.boolean(),
39
+ isDeleted: z.boolean(),
40
+ addedAt: z.string().nullable(),
41
+ completedAt: z.string().nullable(),
42
+ updatedAt: z.string().nullable(),
43
+ due: DueDateSchema.nullable(),
44
+ priority: z.number().int(),
45
+ childOrder: z.number().int(),
46
+ content: z.string(),
47
+ description: z.string(),
48
+ dayOrder: z.number().int(),
49
+ isCollapsed: z.boolean(),
50
+ isUncompletable: z.boolean().default(false),
51
+ })
52
+ .transform((data) => {
53
+ // Auto-detect uncompletable status from content prefix
54
+ const isUncompletable = hasUncompletablePrefix(data.content);
55
+ return Object.assign(Object.assign({}, data), { isUncompletable, url: getTaskUrl(data.id, data.content) });
56
+ });
@@ -0,0 +1 @@
1
+ export * from './requests.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export * from './requests.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export * from './types.js';
@@ -0,0 +1,48 @@
1
+ import { z } from 'zod';
2
+ export const UserSchema = z.object({
3
+ id: z.string(),
4
+ name: z.string(),
5
+ email: z.string(),
6
+ });
7
+ export const TimezoneInfoSchema = z.object({
8
+ gmtString: z.string(),
9
+ hours: z.number().int(),
10
+ isDst: z.number().int(),
11
+ minutes: z.number().int(),
12
+ timezone: z.string(),
13
+ });
14
+ /** Available user premium statuses. */
15
+ export const PREMIUM_STATUSES = [
16
+ 'not_premium',
17
+ 'current_personal_plan',
18
+ 'legacy_personal_plan',
19
+ 'teams_business_member',
20
+ ];
21
+ export const CurrentUserSchema = z.object({
22
+ id: z.string(),
23
+ email: z.string(),
24
+ fullName: z.string(),
25
+ avatarBig: z.string().nullish(),
26
+ avatarMedium: z.string().nullish(),
27
+ avatarS640: z.string().nullish(),
28
+ avatarSmall: z.string().nullish(),
29
+ businessAccountId: z.string().nullable(),
30
+ isPremium: z.boolean(),
31
+ premiumStatus: z.enum(PREMIUM_STATUSES),
32
+ dateFormat: z.number().int(),
33
+ timeFormat: z.number().int(),
34
+ weeklyGoal: z.number().int(),
35
+ dailyGoal: z.number().int(),
36
+ completedCount: z.number().int(),
37
+ completedToday: z.number().int(),
38
+ karma: z.number(),
39
+ karmaTrend: z.string(),
40
+ lang: z.string(),
41
+ nextWeek: z.number().int(),
42
+ startDay: z.number().int(),
43
+ startPage: z.string(),
44
+ tzInfo: TimezoneInfoSchema,
45
+ inboxProjectId: z.string(),
46
+ daysOff: z.array(z.number().int()),
47
+ weekendStartDay: z.number().int(),
48
+ });
@@ -0,0 +1,2 @@
1
+ export * from './types.js';
2
+ export * from './requests.js';
@@ -0,0 +1 @@
1
+ export {};