@doist/todoist-api-typescript 7.6.0 → 7.7.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 (162) hide show
  1. package/dist/cjs/todoist-api.js +8 -7
  2. package/dist/cjs/types/activity/index.js +18 -0
  3. package/dist/cjs/types/activity/requests.js +2 -0
  4. package/dist/cjs/types/activity/types.js +28 -0
  5. package/dist/cjs/types/backups/index.js +18 -0
  6. package/dist/cjs/types/backups/requests.js +2 -0
  7. package/dist/cjs/types/backups/types.js +8 -0
  8. package/dist/cjs/types/comments/index.js +18 -0
  9. package/dist/cjs/types/comments/requests.js +2 -0
  10. package/dist/cjs/types/comments/types.js +60 -0
  11. package/dist/cjs/types/common.js +2 -0
  12. package/dist/cjs/types/emails/index.js +17 -0
  13. package/dist/cjs/types/emails/requests.js +5 -0
  14. package/dist/cjs/types/id-mappings/index.js +18 -0
  15. package/dist/cjs/types/{requests.js → id-mappings/requests.js} +1 -7
  16. package/dist/cjs/types/id-mappings/types.js +12 -0
  17. package/dist/cjs/types/index.js +16 -2
  18. package/dist/cjs/types/insights/index.js +18 -0
  19. package/dist/cjs/types/insights/requests.js +2 -0
  20. package/dist/cjs/types/insights/types.js +84 -0
  21. package/dist/cjs/types/labels/index.js +18 -0
  22. package/dist/cjs/types/labels/requests.js +2 -0
  23. package/dist/cjs/types/labels/types.js +11 -0
  24. package/dist/cjs/types/productivity/index.js +17 -0
  25. package/dist/cjs/types/productivity/types.js +67 -0
  26. package/dist/cjs/types/projects/index.js +18 -0
  27. package/dist/cjs/types/projects/requests.js +2 -0
  28. package/dist/cjs/types/projects/types.js +56 -0
  29. package/dist/cjs/types/reminders/index.js +17 -0
  30. package/dist/cjs/types/reminders/requests.js +5 -0
  31. package/dist/cjs/types/sections/index.js +18 -0
  32. package/dist/cjs/types/sections/requests.js +2 -0
  33. package/dist/cjs/types/sections/types.js +22 -0
  34. package/dist/cjs/types/sync/commands/shared.js +2 -2
  35. package/dist/cjs/types/sync/resources/collaborators.js +2 -2
  36. package/dist/cjs/types/sync/resources/notes.js +2 -2
  37. package/dist/cjs/types/sync/resources/reminders.js +3 -3
  38. package/dist/cjs/types/sync/resources/user.js +2 -2
  39. package/dist/cjs/types/sync/resources/workspaces.js +5 -5
  40. package/dist/cjs/types/tasks/index.js +18 -0
  41. package/dist/cjs/types/tasks/requests.js +2 -0
  42. package/dist/cjs/types/tasks/types.js +59 -0
  43. package/dist/cjs/types/templates/index.js +17 -0
  44. package/dist/cjs/types/templates/requests.js +2 -0
  45. package/dist/cjs/types/uploads/index.js +17 -0
  46. package/dist/cjs/types/uploads/requests.js +2 -0
  47. package/dist/cjs/types/users/index.js +17 -0
  48. package/dist/cjs/types/users/types.js +51 -0
  49. package/dist/cjs/types/workspaces/index.js +18 -0
  50. package/dist/cjs/types/workspaces/requests.js +2 -0
  51. package/dist/cjs/types/workspaces/types.js +137 -0
  52. package/dist/cjs/utils/validators.js +38 -27
  53. package/dist/esm/todoist-api.js +4 -3
  54. package/dist/esm/types/activity/index.js +2 -0
  55. package/dist/esm/types/activity/requests.js +1 -0
  56. package/dist/esm/types/activity/types.js +25 -0
  57. package/dist/esm/types/backups/index.js +2 -0
  58. package/dist/esm/types/backups/requests.js +1 -0
  59. package/dist/esm/types/backups/types.js +5 -0
  60. package/dist/esm/types/comments/index.js +2 -0
  61. package/dist/esm/types/comments/requests.js +1 -0
  62. package/dist/esm/types/comments/types.js +57 -0
  63. package/dist/esm/types/common.js +1 -0
  64. package/dist/esm/types/emails/index.js +1 -0
  65. package/dist/esm/types/emails/requests.js +2 -0
  66. package/dist/esm/types/id-mappings/index.js +2 -0
  67. package/dist/esm/types/{requests.js → id-mappings/requests.js} +0 -6
  68. package/dist/esm/types/id-mappings/types.js +9 -0
  69. package/dist/esm/types/index.js +16 -2
  70. package/dist/esm/types/insights/index.js +2 -0
  71. package/dist/esm/types/insights/requests.js +1 -0
  72. package/dist/esm/types/insights/types.js +81 -0
  73. package/dist/esm/types/labels/index.js +2 -0
  74. package/dist/esm/types/labels/requests.js +1 -0
  75. package/dist/esm/types/labels/types.js +8 -0
  76. package/dist/esm/types/productivity/index.js +1 -0
  77. package/dist/esm/types/productivity/types.js +64 -0
  78. package/dist/esm/types/projects/index.js +2 -0
  79. package/dist/esm/types/projects/requests.js +1 -0
  80. package/dist/esm/types/projects/types.js +53 -0
  81. package/dist/esm/types/reminders/index.js +1 -0
  82. package/dist/esm/types/reminders/requests.js +2 -0
  83. package/dist/esm/types/sections/index.js +2 -0
  84. package/dist/esm/types/sections/requests.js +1 -0
  85. package/dist/esm/types/sections/types.js +19 -0
  86. package/dist/esm/types/sync/commands/shared.js +1 -1
  87. package/dist/esm/types/sync/resources/collaborators.js +1 -1
  88. package/dist/esm/types/sync/resources/notes.js +1 -1
  89. package/dist/esm/types/sync/resources/reminders.js +1 -1
  90. package/dist/esm/types/sync/resources/user.js +1 -1
  91. package/dist/esm/types/sync/resources/workspaces.js +1 -1
  92. package/dist/esm/types/tasks/index.js +2 -0
  93. package/dist/esm/types/tasks/requests.js +1 -0
  94. package/dist/esm/types/tasks/types.js +56 -0
  95. package/dist/esm/types/templates/index.js +1 -0
  96. package/dist/esm/types/templates/requests.js +1 -0
  97. package/dist/esm/types/uploads/index.js +1 -0
  98. package/dist/esm/types/uploads/requests.js +1 -0
  99. package/dist/esm/types/users/index.js +1 -0
  100. package/dist/esm/types/users/types.js +48 -0
  101. package/dist/esm/types/workspaces/index.js +2 -0
  102. package/dist/esm/types/workspaces/requests.js +1 -0
  103. package/dist/esm/types/workspaces/types.js +134 -0
  104. package/dist/esm/utils/validators.js +12 -1
  105. package/dist/types/test-utils/test-defaults.d.ts +5 -5
  106. package/dist/types/todoist-api.d.ts +16 -2
  107. package/dist/types/types/activity/index.d.ts +2 -0
  108. package/dist/types/types/activity/requests.d.ts +85 -0
  109. package/dist/types/types/activity/types.d.ts +49 -0
  110. package/dist/types/types/backups/index.d.ts +2 -0
  111. package/dist/types/types/backups/requests.d.ts +16 -0
  112. package/dist/types/types/backups/types.d.ts +7 -0
  113. package/dist/types/types/comments/index.d.ts +2 -0
  114. package/dist/types/types/comments/requests.d.ts +64 -0
  115. package/dist/types/types/comments/types.d.ts +141 -0
  116. package/dist/types/types/common.d.ts +6 -0
  117. package/dist/types/types/emails/index.d.ts +1 -0
  118. package/dist/types/types/emails/requests.d.ts +30 -0
  119. package/dist/types/types/id-mappings/index.d.ts +2 -0
  120. package/dist/types/types/id-mappings/requests.d.ts +28 -0
  121. package/dist/types/types/id-mappings/types.d.ts +13 -0
  122. package/dist/types/types/index.d.ts +16 -2
  123. package/dist/types/types/insights/index.d.ts +2 -0
  124. package/dist/types/types/insights/requests.d.ts +26 -0
  125. package/dist/types/types/insights/types.d.ts +186 -0
  126. package/dist/types/types/labels/index.d.ts +2 -0
  127. package/dist/types/types/labels/requests.d.ts +75 -0
  128. package/dist/types/types/labels/types.d.ts +13 -0
  129. package/dist/types/types/productivity/index.d.ts +1 -0
  130. package/dist/types/types/productivity/types.d.ts +115 -0
  131. package/dist/types/types/projects/index.d.ts +2 -0
  132. package/dist/types/types/projects/requests.d.ts +169 -0
  133. package/dist/types/types/projects/types.d.ts +201 -0
  134. package/dist/types/types/reminders/index.d.ts +1 -0
  135. package/dist/types/types/reminders/requests.d.ts +91 -0
  136. package/dist/types/types/sections/index.d.ts +2 -0
  137. package/dist/types/types/sections/requests.d.ts +41 -0
  138. package/dist/types/types/sections/types.d.ts +44 -0
  139. package/dist/types/types/sync/commands/projects.d.ts +2 -1
  140. package/dist/types/types/sync/commands/shared.d.ts +2 -2
  141. package/dist/types/types/sync/commands/workspaces.d.ts +1 -1
  142. package/dist/types/types/sync/resources/notes.d.ts +1 -1
  143. package/dist/types/types/sync/response.d.ts +5 -1
  144. package/dist/types/types/tasks/index.d.ts +2 -0
  145. package/dist/types/types/tasks/requests.d.ts +197 -0
  146. package/dist/types/types/tasks/types.d.ts +162 -0
  147. package/dist/types/types/templates/index.d.ts +1 -0
  148. package/dist/types/types/templates/requests.d.ts +92 -0
  149. package/dist/types/types/uploads/index.d.ts +1 -0
  150. package/dist/types/types/uploads/requests.d.ts +32 -0
  151. package/dist/types/types/users/index.d.ts +1 -0
  152. package/dist/types/types/users/types.d.ts +66 -0
  153. package/dist/types/types/workspaces/index.d.ts +2 -0
  154. package/dist/types/types/workspaces/requests.d.ts +260 -0
  155. package/dist/types/types/workspaces/types.d.ts +225 -0
  156. package/dist/types/utils/colors.d.ts +1 -1
  157. package/dist/types/utils/validators.d.ts +7 -6
  158. package/package.json +3 -3
  159. package/dist/cjs/types/entities.js +0 -552
  160. package/dist/esm/types/entities.js +0 -548
  161. package/dist/types/types/entities.d.ts +0 -1211
  162. package/dist/types/types/requests.d.ts +0 -1188
@@ -1,548 +0,0 @@
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
- import { getProjectUrl, getTaskUrl, getSectionUrl } from '../utils/url-helpers.js';
14
- import { hasUncompletablePrefix } from '../utils/uncompletable-helpers.js';
15
- export const DueDateSchema = z
16
- .object({
17
- isRecurring: z.boolean(),
18
- string: z.string(),
19
- date: z.string(),
20
- })
21
- .extend({
22
- datetime: z.string().nullable().optional(),
23
- timezone: z.string().nullable().optional(),
24
- lang: z.string().nullable().optional(),
25
- });
26
- /** Available duration units for task deadlines. */
27
- export const DURATION_UNITS = ['minute', 'day'];
28
- export const DurationSchema = z.object({
29
- amount: z.number().positive('Value should be greater than zero'),
30
- unit: z.enum(DURATION_UNITS),
31
- });
32
- export const DeadlineSchema = z.object({
33
- date: z.string(),
34
- lang: z.string(),
35
- });
36
- export const TaskSchema = z
37
- .object({
38
- id: z.string(),
39
- userId: z.string(),
40
- projectId: z.string(),
41
- sectionId: z.string().nullable(),
42
- parentId: z.string().nullable(),
43
- addedByUid: z.string().nullable(),
44
- assignedByUid: z.string().nullable(),
45
- responsibleUid: z.string().nullable(),
46
- labels: z.array(z.string()),
47
- deadline: DeadlineSchema.nullable(),
48
- duration: DurationSchema.nullable(),
49
- checked: z.boolean(),
50
- isDeleted: z.boolean(),
51
- addedAt: z.string().nullable(),
52
- completedAt: z.string().nullable(),
53
- updatedAt: z.string().nullable(),
54
- due: DueDateSchema.nullable(),
55
- priority: z.number().int(),
56
- childOrder: z.number().int(),
57
- content: z.string(),
58
- description: z.string(),
59
- dayOrder: z.number().int(),
60
- isCollapsed: z.boolean(),
61
- isUncompletable: z.boolean().default(false),
62
- })
63
- .transform((data) => {
64
- // Auto-detect uncompletable status from content prefix
65
- const isUncompletable = hasUncompletablePrefix(data.content);
66
- return Object.assign(Object.assign({}, data), { isUncompletable, url: getTaskUrl(data.id, data.content) });
67
- });
68
- /**
69
- * Base schema for all project types in Todoist.
70
- * Contains common fields shared between personal and workspace projects.
71
- */
72
- export const BaseProjectSchema = z.object({
73
- id: z.string(),
74
- canAssignTasks: z.boolean(),
75
- childOrder: z.number().int(),
76
- color: z.string(),
77
- createdAt: z.string().nullable(),
78
- isArchived: z.boolean(),
79
- isDeleted: z.boolean(),
80
- isFavorite: z.boolean(),
81
- isFrozen: z.boolean(),
82
- name: z.string(),
83
- updatedAt: z.string().nullable(),
84
- viewStyle: z.string(),
85
- defaultOrder: z.number().int(),
86
- description: z.string(),
87
- isCollapsed: z.boolean(),
88
- isShared: z.boolean(),
89
- });
90
- /**
91
- * Schema for personal projects in Todoist.
92
- */
93
- export const PersonalProjectSchema = BaseProjectSchema.extend({
94
- parentId: z.string().nullable(),
95
- inboxProject: z.boolean().optional().default(false),
96
- }).transform((data) => {
97
- return Object.assign(Object.assign({}, data), { url: getProjectUrl(data.id, data.name) });
98
- });
99
- /** Available project visibility levels. */
100
- export const PROJECT_VISIBILITIES = ['restricted', 'team', 'public'];
101
- export const ProjectVisibilitySchema = z.enum(PROJECT_VISIBILITIES);
102
- /**
103
- * Schema for workspace projects in Todoist.
104
- */
105
- export const WorkspaceProjectSchema = BaseProjectSchema.extend({
106
- access: z.object({ visibility: ProjectVisibilitySchema }).optional(),
107
- collaboratorRoleDefault: z.string(),
108
- folderId: z.string().nullable(),
109
- isInviteOnly: z.boolean().nullable(),
110
- isLinkSharingEnabled: z.boolean(),
111
- role: z.string().nullable(),
112
- status: z.string(),
113
- workspaceId: z.string(),
114
- }).transform((data) => {
115
- return Object.assign(Object.assign({}, data), { url: getProjectUrl(data.id, data.name) });
116
- });
117
- /** Available project view styles. */
118
- export const PROJECT_VIEW_STYLES = ['list', 'board', 'calendar'];
119
- export const SectionSchema = z
120
- .object({
121
- id: z.string(),
122
- userId: z.string(),
123
- projectId: z.string(),
124
- addedAt: z.string(),
125
- updatedAt: z.string(),
126
- archivedAt: z.string().nullable(),
127
- name: z.string(),
128
- sectionOrder: z.number().int(),
129
- isArchived: z.boolean(),
130
- isDeleted: z.boolean(),
131
- isCollapsed: z.boolean(),
132
- })
133
- .transform((data) => {
134
- return Object.assign(Object.assign({}, data), { url: getSectionUrl(data.id, data.name) });
135
- });
136
- export const LabelSchema = z.object({
137
- id: z.string(),
138
- order: z.number().int().nullable(),
139
- name: z.string(),
140
- color: z.string(),
141
- isFavorite: z.boolean(),
142
- });
143
- /** Available file attachment upload states. */
144
- export const UPLOAD_STATES = ['pending', 'completed'];
145
- export const AttachmentSchema = z
146
- .object({
147
- resourceType: z.string(),
148
- })
149
- .extend({
150
- fileName: z.string().nullable().optional(),
151
- fileSize: z.number().int().nullable().optional(),
152
- fileType: z.string().nullable().optional(),
153
- fileUrl: z.string().nullable().optional(),
154
- fileDuration: z.number().int().nullable().optional(),
155
- uploadState: z.enum(UPLOAD_STATES).nullable().optional(),
156
- image: z.string().nullable().optional(),
157
- imageWidth: z.number().int().nullable().optional(),
158
- imageHeight: z.number().int().nullable().optional(),
159
- url: z.string().nullable().optional(),
160
- title: z.string().nullable().optional(),
161
- });
162
- export const RawCommentSchema = z
163
- .object({
164
- id: z.string(),
165
- itemId: z.string().optional(),
166
- projectId: z.string().optional(),
167
- content: z.string(),
168
- postedAt: z.string(),
169
- fileAttachment: AttachmentSchema.nullable(),
170
- postedUid: z.string(),
171
- uidsToNotify: z.array(z.string()).nullable(),
172
- reactions: z.record(z.string(), z.array(z.string())).nullable(),
173
- isDeleted: z.boolean(),
174
- })
175
- .refine((data) => {
176
- // At least one of itemId or projectId must be present
177
- return ((data.itemId !== undefined && data.projectId === undefined) ||
178
- (data.itemId === undefined && data.projectId !== undefined));
179
- }, {
180
- message: 'Exactly one of itemId or projectId must be provided',
181
- });
182
- export const CommentSchema = RawCommentSchema.transform((data) => {
183
- const { itemId } = data, rest = __rest(data, ["itemId"]);
184
- return Object.assign(Object.assign({}, rest), {
185
- // Map itemId to taskId for backwards compatibility
186
- taskId: itemId });
187
- });
188
- export const UserSchema = z.object({
189
- id: z.string(),
190
- name: z.string(),
191
- email: z.string(),
192
- });
193
- export const TimezoneInfoSchema = z.object({
194
- gmtString: z.string(),
195
- hours: z.number().int(),
196
- isDst: z.number().int(),
197
- minutes: z.number().int(),
198
- timezone: z.string(),
199
- });
200
- /** Available user premium statuses. */
201
- export const PREMIUM_STATUSES = [
202
- 'not_premium',
203
- 'current_personal_plan',
204
- 'legacy_personal_plan',
205
- 'teams_business_member',
206
- ];
207
- export const CurrentUserSchema = z.object({
208
- id: z.string(),
209
- email: z.string(),
210
- fullName: z.string(),
211
- avatarBig: z.string().nullish(),
212
- avatarMedium: z.string().nullish(),
213
- avatarS640: z.string().nullish(),
214
- avatarSmall: z.string().nullish(),
215
- businessAccountId: z.string().nullable(),
216
- isPremium: z.boolean(),
217
- premiumStatus: z.enum(PREMIUM_STATUSES),
218
- dateFormat: z.number().int(),
219
- timeFormat: z.number().int(),
220
- weeklyGoal: z.number().int(),
221
- dailyGoal: z.number().int(),
222
- completedCount: z.number().int(),
223
- completedToday: z.number().int(),
224
- karma: z.number(),
225
- karmaTrend: z.string(),
226
- lang: z.string(),
227
- nextWeek: z.number().int(),
228
- startDay: z.number().int(),
229
- startPage: z.string(),
230
- tzInfo: TimezoneInfoSchema,
231
- inboxProjectId: z.string(),
232
- daysOff: z.array(z.number().int()),
233
- weekendStartDay: z.number().int(),
234
- });
235
- export const StreakSchema = z.object({
236
- count: z.number(),
237
- start: z.string(),
238
- end: z.string(),
239
- });
240
- export const CompletedItemSchema = z.object({
241
- id: z.string(),
242
- completed: z.number(),
243
- });
244
- export const ItemsWithDateSchema = z.object({
245
- items: z.array(CompletedItemSchema),
246
- totalCompleted: z.number(),
247
- });
248
- export const KarmaUpdateSchema = z.object({
249
- time: z.string(),
250
- newKarma: z.number(),
251
- positiveKarma: z.number(),
252
- negativeKarma: z.number(),
253
- positiveKarmaReasons: z.array(z.any()),
254
- negativeKarmaReasons: z.array(z.any()),
255
- });
256
- export const ProductivityStatsSchema = z.object({
257
- completedCount: z.number(),
258
- daysItems: z.array(ItemsWithDateSchema.extend({
259
- date: z.string(),
260
- })),
261
- goals: z.object({
262
- currentDailyStreak: StreakSchema,
263
- currentWeeklyStreak: StreakSchema,
264
- dailyGoal: z.number(),
265
- ignoreDays: z.array(z.number()),
266
- karmaDisabled: z.number(),
267
- lastDailyStreak: StreakSchema,
268
- lastWeeklyStreak: StreakSchema,
269
- maxDailyStreak: StreakSchema,
270
- maxWeeklyStreak: StreakSchema,
271
- user: z.string(),
272
- userId: z.string(),
273
- vacationMode: z.number(),
274
- weeklyGoal: z.number(),
275
- }),
276
- karma: z.number(),
277
- karmaGraphData: z.array(z.object({
278
- date: z.string(),
279
- karmaAvg: z.number(),
280
- })),
281
- karmaLastUpdate: z.number(),
282
- karmaTrend: z.string(),
283
- karmaUpdateReasons: z.array(KarmaUpdateSchema),
284
- projectColors: z.record(z.string(), z.string()),
285
- weekItems: z.array(ItemsWithDateSchema.extend({
286
- from: z.string(),
287
- to: z.string(),
288
- })),
289
- });
290
- export const ColorSchema = z.object({
291
- /** The key of the color (i.e. 'berry_red') */
292
- key: z.string(),
293
- /** The display name of the color (i.e. 'Berry Red') */
294
- displayName: z.string(),
295
- /** The hex value of the color (i.e. '#b8255f') */
296
- hexValue: z.string(),
297
- });
298
- /**
299
- * Flexible object containing event-specific data.
300
- * Uses z.record to accept any properties for forward compatibility.
301
- */
302
- export const ActivityEventExtraDataSchema = z.record(z.string(), z.any()).nullable();
303
- /**
304
- * Activity log event schema. Accepts unknown fields for forward compatibility.
305
- */
306
- export const ActivityEventSchema = z
307
- .object({
308
- objectType: z.string(),
309
- objectId: z.string(),
310
- eventType: z.string(),
311
- eventDate: z.string(),
312
- id: z
313
- .union([z.string(), z.number()])
314
- .transform((val) => { var _a; return (_a = val === null || val === void 0 ? void 0 : val.toString()) !== null && _a !== void 0 ? _a : null; })
315
- .nullable(),
316
- parentProjectId: z.string().nullable(),
317
- parentItemId: z.string().nullable(),
318
- initiatorId: z.string().nullable(),
319
- extraData: ActivityEventExtraDataSchema,
320
- })
321
- .catchall(z.any());
322
- /** Available project collaborator roles. */
323
- export const COLLABORATOR_ROLES = [
324
- 'CREATOR',
325
- 'ADMIN',
326
- 'READ_WRITE',
327
- 'EDIT_ONLY',
328
- 'COMPLETE_ONLY',
329
- ];
330
- /**
331
- * Available workspace roles.
332
- */
333
- export const WORKSPACE_ROLES = ['ADMIN', 'MEMBER', 'GUEST'];
334
- export const WorkspaceRoleSchema = z.enum(WORKSPACE_ROLES);
335
- export const WorkspaceUserSchema = z.object({
336
- userId: z.string(),
337
- workspaceId: z.string(),
338
- userEmail: z.string(),
339
- fullName: z.string(),
340
- timezone: z.string(),
341
- role: WorkspaceRoleSchema,
342
- imageId: z.string().nullable(),
343
- isDeleted: z.boolean().default(false),
344
- });
345
- export const WorkspaceInvitationSchema = z.object({
346
- id: z.string().default('0'),
347
- inviterId: z.string(),
348
- userEmail: z.string(),
349
- workspaceId: z.string(),
350
- role: WorkspaceRoleSchema,
351
- isExistingUser: z.boolean(),
352
- });
353
- export const PlanPriceSchema = z.object({
354
- currency: z.string(),
355
- amount: z.union([z.number(), z.string()]),
356
- interval: z.string().optional(),
357
- });
358
- export const FormattedPriceListingSchema = z.object({
359
- currency: z.string().optional(),
360
- amount: z.number().optional(),
361
- interval: z.string().optional(),
362
- formatted: z.string().optional(),
363
- });
364
- /** Available workspace plan names. */
365
- export const WORKSPACE_CURRENT_PLANS = ['Business', 'Starter'];
366
- /** Available workspace plan statuses. */
367
- export const WORKSPACE_PLAN_STATUSES = [
368
- 'Active',
369
- 'Downgraded',
370
- 'Cancelled',
371
- 'NeverSubscribed',
372
- ];
373
- export const WorkspacePlanDetailsSchema = z.object({
374
- currentMemberCount: z.number(),
375
- currentPlan: z.enum(WORKSPACE_CURRENT_PLANS),
376
- currentPlanStatus: z.enum(WORKSPACE_PLAN_STATUSES),
377
- downgradeAt: z.string().nullable(),
378
- currentActiveProjects: z.number(),
379
- maximumActiveProjects: z.number(),
380
- priceList: z.array(FormattedPriceListingSchema),
381
- workspaceId: z.number(),
382
- isTrialing: z.boolean(),
383
- trialEndsAt: z.string().nullable(),
384
- cancelAtPeriodEnd: z.boolean(),
385
- hasTrialed: z.boolean(),
386
- planPrice: PlanPriceSchema.nullable(),
387
- hasBillingPortal: z.boolean(),
388
- hasBillingPortalSwitchToAnnual: z.boolean(),
389
- });
390
- export const JoinWorkspaceResultSchema = z.object({
391
- customSortingApplied: z.boolean(),
392
- projectSortPreference: z.string(),
393
- role: WorkspaceRoleSchema,
394
- userId: z.string(),
395
- workspaceId: z.string(),
396
- });
397
- /**
398
- * Available workspace plans.
399
- */
400
- export const WORKSPACE_PLANS = ['STARTER', 'BUSINESS'];
401
- export const WorkspacePlanSchema = z.enum(WORKSPACE_PLANS);
402
- /**
403
- * Workspace resource limits.
404
- */
405
- export const WorkspaceLimitsSchema = z
406
- .object({
407
- current: z.record(z.string(), z.any()).nullable(),
408
- next: z.record(z.string(), z.any()).nullable(),
409
- })
410
- .catchall(z.any());
411
- /**
412
- * Workspace properties (flexible object for unknown fields).
413
- */
414
- export const WorkspacePropertiesSchema = z.record(z.string(), z.unknown());
415
- /**
416
- * Represents a workspace in Todoist.
417
- */
418
- export const WorkspaceSchema = z.object({
419
- id: z.string(),
420
- name: z.string(),
421
- plan: WorkspacePlanSchema,
422
- role: WorkspaceRoleSchema,
423
- inviteCode: z.string(),
424
- isLinkSharingEnabled: z.boolean(),
425
- isGuestAllowed: z.boolean(),
426
- limits: WorkspaceLimitsSchema,
427
- logoBig: z.string().nullish(),
428
- logoMedium: z.string().nullish(),
429
- logoSmall: z.string().nullish(),
430
- logoS640: z.string().nullish(),
431
- createdAt: z.string(),
432
- creatorId: z.string(),
433
- properties: WorkspacePropertiesSchema,
434
- });
435
- export const MemberActivityInfoSchema = z.object({
436
- userId: z.string(),
437
- tasksAssigned: z.number().int(),
438
- tasksOverdue: z.number().int(),
439
- });
440
- export const WorkspaceUserTaskSchema = z.object({
441
- id: z.string(),
442
- content: z.string(),
443
- responsibleUid: z.string().nullable(),
444
- due: DueDateSchema.nullable(),
445
- deadline: DeadlineSchema.nullable(),
446
- labels: z.array(z.string()),
447
- notesCount: z.number().int(),
448
- projectId: z.string(),
449
- projectName: z.string(),
450
- priority: z.number().int(),
451
- description: z.string(),
452
- isOverdue: z.boolean(),
453
- });
454
- // Insights entities
455
- export const DayActivitySchema = z.object({
456
- date: z.string(),
457
- totalCount: z.number().int(),
458
- });
459
- export const WeekRollupSchema = z.object({
460
- fromDate: z.string(),
461
- toDate: z.string(),
462
- totalCount: z.number().int(),
463
- });
464
- export const ProjectActivityStatsSchema = z.object({
465
- dayItems: z.array(DayActivitySchema),
466
- weekItems: z.array(WeekRollupSchema).nullable(),
467
- });
468
- /** Available project health statuses. */
469
- export const HEALTH_STATUSES = [
470
- 'UNKNOWN',
471
- 'ON_TRACK',
472
- 'AT_RISK',
473
- 'CRITICAL',
474
- 'EXCELLENT',
475
- 'ERROR',
476
- ];
477
- export const TaskRecommendationSchema = z.object({
478
- taskId: z.string(),
479
- recommendation: z.string(),
480
- });
481
- export const ProjectHealthSchema = z.object({
482
- status: z.enum(HEALTH_STATUSES),
483
- description: z.string().nullable().optional(),
484
- descriptionSummary: z.string().nullable().optional(),
485
- taskRecommendations: z.array(TaskRecommendationSchema).nullable().optional(),
486
- projectId: z.string().nullable().optional(),
487
- updatedAt: z.string().nullable().optional(),
488
- isStale: z.boolean().default(false),
489
- updateInProgress: z.boolean().default(false),
490
- });
491
- export const ProjectMetricsSchema = z.object({
492
- totalTasks: z.number().int(),
493
- completedTasks: z.number().int(),
494
- overdueTasks: z.number().int(),
495
- tasksCreatedThisWeek: z.number().int(),
496
- tasksCompletedThisWeek: z.number().int(),
497
- averageCompletionTime: z.number().nullable(),
498
- });
499
- export const TaskContextSchema = z.object({
500
- id: z.string(),
501
- content: z.string(),
502
- due: z.string().nullable().optional(),
503
- deadline: z.string().nullable().optional(),
504
- priority: z.string(),
505
- isCompleted: z.boolean(),
506
- createdAt: z.string(),
507
- updatedAt: z.string(),
508
- completedAt: z.string().nullable(),
509
- completedByUid: z.string().nullable(),
510
- labels: z.array(z.string()),
511
- });
512
- export const ProjectHealthContextSchema = z.object({
513
- projectId: z.string(),
514
- projectName: z.string(),
515
- projectDescription: z.string().nullable(),
516
- projectMetrics: ProjectMetricsSchema,
517
- tasks: z.array(TaskContextSchema),
518
- language: z.string().nullable().optional(),
519
- });
520
- export const ProjectProgressSchema = z.object({
521
- projectId: z.string(),
522
- completedCount: z.number().int(),
523
- activeCount: z.number().int(),
524
- progressPercent: z.number().int(),
525
- });
526
- export const ProjectInsightSchema = z.object({
527
- projectId: z.string(),
528
- health: ProjectHealthSchema.nullable(),
529
- progress: ProjectProgressSchema.nullable(),
530
- });
531
- export const WorkspaceInsightsSchema = z.object({
532
- folderId: z.string().nullable(),
533
- projectInsights: z.array(ProjectInsightSchema),
534
- });
535
- // Backups
536
- export const BackupSchema = z.object({
537
- version: z.string(),
538
- url: z.string(),
539
- });
540
- // ID Mappings
541
- export const IdMappingSchema = z.object({
542
- oldId: z.string().nullable(),
543
- newId: z.string().nullable(),
544
- });
545
- export const MovedIdSchema = z.object({
546
- oldId: z.string(),
547
- newId: z.string(),
548
- });