@doist/todoist-api-typescript 7.1.1 → 7.3.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/dist/cjs/test-utils/msw-setup.js +4 -3
  2. package/dist/cjs/todoist-api.js +105 -0
  3. package/dist/cjs/types/entities.js +43 -26
  4. package/dist/cjs/types/sync/resources/calendars.js +7 -3
  5. package/dist/cjs/types/sync/resources/collaborators.js +4 -2
  6. package/dist/cjs/types/sync/resources/reminders.js +8 -6
  7. package/dist/cjs/types/sync/resources/suggestions.js +11 -7
  8. package/dist/cjs/types/sync/resources/user-settings.js +5 -5
  9. package/dist/cjs/types/sync/resources/user.js +11 -15
  10. package/dist/cjs/types/sync/resources/view-options.js +33 -25
  11. package/dist/esm/test-utils/msw-setup.js +1 -0
  12. package/dist/esm/todoist-api.js +105 -0
  13. package/dist/esm/types/entities.js +32 -15
  14. package/dist/esm/types/sync/resources/calendars.js +6 -2
  15. package/dist/esm/types/sync/resources/collaborators.js +3 -1
  16. package/dist/esm/types/sync/resources/reminders.js +4 -2
  17. package/dist/esm/types/sync/resources/suggestions.js +8 -4
  18. package/dist/esm/types/sync/resources/user-settings.js +2 -2
  19. package/dist/esm/types/sync/resources/user.js +6 -10
  20. package/dist/esm/types/sync/resources/view-options.js +22 -14
  21. package/dist/types/todoist-api.d.ts +31 -20
  22. package/dist/types/types/entities.d.ts +48 -1
  23. package/dist/types/types/sync/commands/project-view-options.d.ts +2 -2
  24. package/dist/types/types/sync/commands/view-options.d.ts +3 -7
  25. package/dist/types/types/sync/resources/calendars.d.ts +8 -0
  26. package/dist/types/types/sync/resources/collaborators.d.ts +4 -0
  27. package/dist/types/types/sync/resources/reminders.d.ts +11 -0
  28. package/dist/types/types/sync/resources/suggestions.d.ts +42 -0
  29. package/dist/types/types/sync/resources/user-settings.d.ts +8 -0
  30. package/dist/types/types/sync/resources/user.d.ts +30 -0
  31. package/dist/types/types/sync/resources/view-options.d.ts +75 -0
  32. package/package.json +5 -5
@@ -7,6 +7,7 @@ exports.getAllRequests = getAllRequests;
7
7
  exports.clearCapturedRequests = clearCapturedRequests;
8
8
  exports.mockApiResponse = mockApiResponse;
9
9
  exports.mockApiError = mockApiError;
10
+ const vitest_1 = require("vitest");
10
11
  const node_1 = require("msw/node");
11
12
  const msw_1 = require("msw");
12
13
  Object.defineProperty(exports, "http", { enumerable: true, get: function () { return msw_1.http; } });
@@ -82,15 +83,15 @@ function mockApiError({ endpoint, data, status, options = {}, }) {
82
83
  mockApiResponse({ endpoint, data, options: Object.assign(Object.assign({}, options), { status }) });
83
84
  }
84
85
  // Setup MSW for tests
85
- beforeAll(() => {
86
+ (0, vitest_1.beforeAll)(() => {
86
87
  exports.server.listen({
87
88
  onUnhandledRequest: 'error', // Throw errors for unhandled requests to catch unexpected fetch calls
88
89
  });
89
90
  });
90
- afterEach(() => {
91
+ (0, vitest_1.afterEach)(() => {
91
92
  exports.server.resetHandlers(); // Reset handlers between tests
92
93
  clearCapturedRequests(); // Clear captured requests between tests
93
94
  });
94
- afterAll(() => {
95
+ (0, vitest_1.afterAll)(() => {
95
96
  exports.server.close(); // Clean up after all tests
96
97
  });
@@ -55,6 +55,34 @@ function preprocessSyncCommands(commands) {
55
55
  return cmd;
56
56
  });
57
57
  }
58
+ /**
59
+ * A client for interacting with the Todoist API v1.
60
+ * This class provides methods to manage tasks, projects, sections, labels, and comments in Todoist.
61
+ *
62
+ * @example
63
+ * ```typescript
64
+ * const api = new TodoistApi('your-api-token');
65
+ *
66
+ * // Get all tasks
67
+ * const tasks = await api.getTasks();
68
+ *
69
+ * // Create a new task
70
+ * const newTask = await api.addTask({
71
+ * content: 'My new task',
72
+ * projectId: '12345'
73
+ * });
74
+ * ```
75
+ *
76
+ * For more information about the Todoist API v1, see the [official documentation](https://todoist.com/api/v1).
77
+ * If you're migrating from v9, please refer to the [migration guide](https://todoist.com/api/v1/docs#tag/Migrating-from-v9).
78
+ */
79
+ function headersToRecord(headers) {
80
+ const result = {};
81
+ headers.forEach((value, key) => {
82
+ result[key] = value;
83
+ });
84
+ return result;
85
+ }
58
86
  class TodoistApi {
59
87
  constructor(
60
88
  /**
@@ -1194,6 +1222,83 @@ class TodoistApi {
1194
1222
  });
1195
1223
  return (0, rest_client_1.isSuccess)(response);
1196
1224
  }
1225
+ /**
1226
+ * Fetches the content of a file attachment from a Todoist comment.
1227
+ *
1228
+ * Accepts either a Comment object (extracts the file URL from its attachment)
1229
+ * or a direct file URL string. Returns the raw Response object so the caller
1230
+ * can read the body in the appropriate format (.arrayBuffer(), .text(), etc.).
1231
+ *
1232
+ * @param commentOrUrl - A Comment object with a file attachment, or a file URL string.
1233
+ * @returns The raw fetch Response for the file content.
1234
+ * @throws Error if a Comment is provided without a file attachment or file URL.
1235
+ *
1236
+ * @example
1237
+ * ```typescript
1238
+ * // From a comment object
1239
+ * const comments = await api.getComments({ taskId: '12345' })
1240
+ * const comment = comments.results[0]
1241
+ * const response = await api.viewAttachment(comment)
1242
+ * const imageData = await response.arrayBuffer()
1243
+ *
1244
+ * // From a URL string
1245
+ * const response = await api.viewAttachment('https://files.todoist.com/...')
1246
+ * const text = await response.text()
1247
+ * ```
1248
+ */
1249
+ async viewAttachment(commentOrUrl) {
1250
+ var _a;
1251
+ let fileUrl;
1252
+ if (typeof commentOrUrl === 'string') {
1253
+ fileUrl = commentOrUrl;
1254
+ }
1255
+ else {
1256
+ if (!((_a = commentOrUrl.fileAttachment) === null || _a === void 0 ? void 0 : _a.fileUrl)) {
1257
+ throw new Error('Comment does not have a file attachment');
1258
+ }
1259
+ fileUrl = commentOrUrl.fileAttachment.fileUrl;
1260
+ }
1261
+ // Validate the URL belongs to Todoist to prevent leaking the auth token
1262
+ const urlHostname = new URL(fileUrl).hostname;
1263
+ if (!urlHostname.endsWith('.todoist.com')) {
1264
+ throw new Error('Attachment URLs must be on a todoist.com domain');
1265
+ }
1266
+ const fetchOptions = {
1267
+ method: 'GET',
1268
+ headers: { Authorization: `Bearer ${this.authToken}` },
1269
+ };
1270
+ if (this.customFetch) {
1271
+ const response = await this.customFetch(fileUrl, fetchOptions);
1272
+ if (!response.ok) {
1273
+ throw new Error(`Failed to fetch attachment: ${response.status} ${response.statusText}`);
1274
+ }
1275
+ // Convert text to ArrayBuffer for custom fetch implementations that lack arrayBuffer()
1276
+ const text = await response.text();
1277
+ const buffer = new TextEncoder().encode(text).buffer;
1278
+ return {
1279
+ ok: response.ok,
1280
+ status: response.status,
1281
+ statusText: response.statusText,
1282
+ headers: response.headers,
1283
+ text: () => Promise.resolve(text),
1284
+ json: () => response.json(),
1285
+ arrayBuffer: () => Promise.resolve(buffer),
1286
+ };
1287
+ }
1288
+ const response = await fetch(fileUrl, fetchOptions);
1289
+ if (!response.ok) {
1290
+ throw new Error(`Failed to fetch attachment: ${response.status} ${response.statusText}`);
1291
+ }
1292
+ return {
1293
+ ok: response.ok,
1294
+ status: response.status,
1295
+ statusText: response.statusText,
1296
+ headers: headersToRecord(response.headers),
1297
+ text: () => response.text(),
1298
+ json: () => response.json(),
1299
+ arrayBuffer: () => response.arrayBuffer(),
1300
+ };
1301
+ }
1197
1302
  /* Workspace methods */
1198
1303
  /**
1199
1304
  * Gets pending invitations for a workspace.
@@ -11,7 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  return t;
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.WorkspaceSchema = exports.WorkspacePropertiesSchema = exports.WorkspaceLimitsSchema = exports.WorkspacePlanSchema = exports.WORKSPACE_PLANS = exports.JoinWorkspaceResultSchema = exports.WorkspacePlanDetailsSchema = exports.FormattedPriceListingSchema = exports.PlanPriceSchema = exports.WorkspaceInvitationSchema = exports.WorkspaceUserSchema = exports.WorkspaceRoleSchema = exports.WORKSPACE_ROLES = exports.ActivityEventSchema = exports.ActivityEventExtraDataSchema = exports.ColorSchema = exports.ProductivityStatsSchema = exports.CurrentUserSchema = exports.TimezoneInfoSchema = exports.UserSchema = exports.CommentSchema = exports.RawCommentSchema = exports.AttachmentSchema = exports.LabelSchema = exports.SectionSchema = exports.WorkspaceProjectSchema = exports.ProjectVisibilitySchema = exports.PersonalProjectSchema = exports.BaseProjectSchema = exports.TaskSchema = exports.DeadlineSchema = exports.DurationSchema = exports.DueDateSchema = void 0;
14
+ exports.WorkspaceSchema = exports.WorkspacePropertiesSchema = exports.WorkspaceLimitsSchema = exports.WorkspacePlanSchema = exports.WORKSPACE_PLANS = exports.JoinWorkspaceResultSchema = exports.WorkspacePlanDetailsSchema = exports.WORKSPACE_PLAN_STATUSES = exports.WORKSPACE_CURRENT_PLANS = exports.FormattedPriceListingSchema = exports.PlanPriceSchema = exports.WorkspaceInvitationSchema = exports.WorkspaceUserSchema = exports.WorkspaceRoleSchema = exports.WORKSPACE_ROLES = exports.ActivityEventSchema = exports.ActivityEventExtraDataSchema = exports.ColorSchema = exports.ProductivityStatsSchema = exports.KarmaUpdateSchema = exports.ItemsWithDateSchema = exports.CompletedItemSchema = exports.StreakSchema = exports.CurrentUserSchema = exports.PREMIUM_STATUSES = exports.TimezoneInfoSchema = exports.UserSchema = exports.CommentSchema = exports.RawCommentSchema = exports.AttachmentSchema = exports.UPLOAD_STATES = exports.LabelSchema = exports.SectionSchema = exports.WorkspaceProjectSchema = exports.ProjectVisibilitySchema = exports.PROJECT_VISIBILITIES = exports.PersonalProjectSchema = exports.BaseProjectSchema = exports.TaskSchema = exports.DeadlineSchema = exports.DurationSchema = exports.DURATION_UNITS = exports.DueDateSchema = void 0;
15
15
  const zod_1 = require("zod");
16
16
  const url_helpers_1 = require("../utils/url-helpers");
17
17
  const uncompletable_helpers_1 = require("../utils/uncompletable-helpers");
@@ -26,9 +26,11 @@ exports.DueDateSchema = zod_1.z
26
26
  timezone: zod_1.z.string().nullable().optional(),
27
27
  lang: zod_1.z.string().nullable().optional(),
28
28
  });
29
+ /** Available duration units for task deadlines. */
30
+ exports.DURATION_UNITS = ['minute', 'day'];
29
31
  exports.DurationSchema = zod_1.z.object({
30
32
  amount: zod_1.z.number().positive('Value should be greater than zero'),
31
- unit: zod_1.z.enum(['minute', 'day']),
33
+ unit: zod_1.z.enum(exports.DURATION_UNITS),
32
34
  });
33
35
  exports.DeadlineSchema = zod_1.z.object({
34
36
  date: zod_1.z.string(),
@@ -97,7 +99,9 @@ exports.PersonalProjectSchema = exports.BaseProjectSchema.extend({
97
99
  }).transform((data) => {
98
100
  return Object.assign(Object.assign({}, data), { url: (0, url_helpers_1.getProjectUrl)(data.id, data.name) });
99
101
  });
100
- exports.ProjectVisibilitySchema = zod_1.z.enum(['restricted', 'team', 'public']);
102
+ /** Available project visibility levels. */
103
+ exports.PROJECT_VISIBILITIES = ['restricted', 'team', 'public'];
104
+ exports.ProjectVisibilitySchema = zod_1.z.enum(exports.PROJECT_VISIBILITIES);
101
105
  /**
102
106
  * Schema for workspace projects in Todoist.
103
107
  */
@@ -137,6 +141,8 @@ exports.LabelSchema = zod_1.z.object({
137
141
  color: zod_1.z.string(),
138
142
  isFavorite: zod_1.z.boolean(),
139
143
  });
144
+ /** Available file attachment upload states. */
145
+ exports.UPLOAD_STATES = ['pending', 'completed'];
140
146
  exports.AttachmentSchema = zod_1.z
141
147
  .object({
142
148
  resourceType: zod_1.z.string(),
@@ -147,7 +153,7 @@ exports.AttachmentSchema = zod_1.z
147
153
  fileType: zod_1.z.string().nullable().optional(),
148
154
  fileUrl: zod_1.z.string().nullable().optional(),
149
155
  fileDuration: zod_1.z.number().int().nullable().optional(),
150
- uploadState: zod_1.z.enum(['pending', 'completed']).nullable().optional(),
156
+ uploadState: zod_1.z.enum(exports.UPLOAD_STATES).nullable().optional(),
151
157
  image: zod_1.z.string().nullable().optional(),
152
158
  imageWidth: zod_1.z.number().int().nullable().optional(),
153
159
  imageHeight: zod_1.z.number().int().nullable().optional(),
@@ -192,6 +198,13 @@ exports.TimezoneInfoSchema = zod_1.z.object({
192
198
  minutes: zod_1.z.number().int(),
193
199
  timezone: zod_1.z.string(),
194
200
  });
201
+ /** Available user premium statuses. */
202
+ exports.PREMIUM_STATUSES = [
203
+ 'not_premium',
204
+ 'current_personal_plan',
205
+ 'legacy_personal_plan',
206
+ 'teams_business_member',
207
+ ];
195
208
  exports.CurrentUserSchema = zod_1.z.object({
196
209
  id: zod_1.z.string(),
197
210
  email: zod_1.z.string(),
@@ -202,12 +215,7 @@ exports.CurrentUserSchema = zod_1.z.object({
202
215
  avatarSmall: zod_1.z.string().nullish(),
203
216
  businessAccountId: zod_1.z.string().nullable(),
204
217
  isPremium: zod_1.z.boolean(),
205
- premiumStatus: zod_1.z.enum([
206
- 'not_premium',
207
- 'current_personal_plan',
208
- 'legacy_personal_plan',
209
- 'teams_business_member',
210
- ]),
218
+ premiumStatus: zod_1.z.enum(exports.PREMIUM_STATUSES),
211
219
  dateFormat: zod_1.z.number().int(),
212
220
  timeFormat: zod_1.z.number().int(),
213
221
  weeklyGoal: zod_1.z.number().int(),
@@ -225,20 +233,20 @@ exports.CurrentUserSchema = zod_1.z.object({
225
233
  daysOff: zod_1.z.array(zod_1.z.number().int()),
226
234
  weekendStartDay: zod_1.z.number().int(),
227
235
  });
228
- const StreakSchema = zod_1.z.object({
236
+ exports.StreakSchema = zod_1.z.object({
229
237
  count: zod_1.z.number(),
230
238
  start: zod_1.z.string(),
231
239
  end: zod_1.z.string(),
232
240
  });
233
- const CompletedItemSchema = zod_1.z.object({
241
+ exports.CompletedItemSchema = zod_1.z.object({
234
242
  id: zod_1.z.string(),
235
243
  completed: zod_1.z.number(),
236
244
  });
237
- const ItemsWithDateSchema = zod_1.z.object({
238
- items: zod_1.z.array(CompletedItemSchema),
245
+ exports.ItemsWithDateSchema = zod_1.z.object({
246
+ items: zod_1.z.array(exports.CompletedItemSchema),
239
247
  totalCompleted: zod_1.z.number(),
240
248
  });
241
- const KarmaUpdateSchema = zod_1.z.object({
249
+ exports.KarmaUpdateSchema = zod_1.z.object({
242
250
  time: zod_1.z.string(),
243
251
  newKarma: zod_1.z.number(),
244
252
  positiveKarma: zod_1.z.number(),
@@ -248,19 +256,19 @@ const KarmaUpdateSchema = zod_1.z.object({
248
256
  });
249
257
  exports.ProductivityStatsSchema = zod_1.z.object({
250
258
  completedCount: zod_1.z.number(),
251
- daysItems: zod_1.z.array(ItemsWithDateSchema.extend({
259
+ daysItems: zod_1.z.array(exports.ItemsWithDateSchema.extend({
252
260
  date: zod_1.z.string(),
253
261
  })),
254
262
  goals: zod_1.z.object({
255
- currentDailyStreak: StreakSchema,
256
- currentWeeklyStreak: StreakSchema,
263
+ currentDailyStreak: exports.StreakSchema,
264
+ currentWeeklyStreak: exports.StreakSchema,
257
265
  dailyGoal: zod_1.z.number(),
258
266
  ignoreDays: zod_1.z.array(zod_1.z.number()),
259
267
  karmaDisabled: zod_1.z.number(),
260
- lastDailyStreak: StreakSchema,
261
- lastWeeklyStreak: StreakSchema,
262
- maxDailyStreak: StreakSchema,
263
- maxWeeklyStreak: StreakSchema,
268
+ lastDailyStreak: exports.StreakSchema,
269
+ lastWeeklyStreak: exports.StreakSchema,
270
+ maxDailyStreak: exports.StreakSchema,
271
+ maxWeeklyStreak: exports.StreakSchema,
264
272
  user: zod_1.z.string(),
265
273
  userId: zod_1.z.string(),
266
274
  vacationMode: zod_1.z.number(),
@@ -273,9 +281,9 @@ exports.ProductivityStatsSchema = zod_1.z.object({
273
281
  })),
274
282
  karmaLastUpdate: zod_1.z.number(),
275
283
  karmaTrend: zod_1.z.string(),
276
- karmaUpdateReasons: zod_1.z.array(KarmaUpdateSchema),
284
+ karmaUpdateReasons: zod_1.z.array(exports.KarmaUpdateSchema),
277
285
  projectColors: zod_1.z.record(zod_1.z.string(), zod_1.z.string()),
278
- weekItems: zod_1.z.array(ItemsWithDateSchema.extend({
286
+ weekItems: zod_1.z.array(exports.ItemsWithDateSchema.extend({
279
287
  from: zod_1.z.string(),
280
288
  to: zod_1.z.string(),
281
289
  })),
@@ -346,10 +354,19 @@ exports.FormattedPriceListingSchema = zod_1.z.object({
346
354
  interval: zod_1.z.string().optional(),
347
355
  formatted: zod_1.z.string().optional(),
348
356
  });
357
+ /** Available workspace plan names. */
358
+ exports.WORKSPACE_CURRENT_PLANS = ['Business', 'Starter'];
359
+ /** Available workspace plan statuses. */
360
+ exports.WORKSPACE_PLAN_STATUSES = [
361
+ 'Active',
362
+ 'Downgraded',
363
+ 'Cancelled',
364
+ 'NeverSubscribed',
365
+ ];
349
366
  exports.WorkspacePlanDetailsSchema = zod_1.z.object({
350
367
  currentMemberCount: zod_1.z.number(),
351
- currentPlan: zod_1.z.enum(['Business', 'Starter']),
352
- currentPlanStatus: zod_1.z.enum(['Active', 'Downgraded', 'Cancelled', 'NeverSubscribed']),
368
+ currentPlan: zod_1.z.enum(exports.WORKSPACE_CURRENT_PLANS),
369
+ currentPlanStatus: zod_1.z.enum(exports.WORKSPACE_PLAN_STATUSES),
353
370
  downgradeAt: zod_1.z.string().nullable(),
354
371
  currentActiveProjects: zod_1.z.number(),
355
372
  maximumActiveProjects: zod_1.z.number(),
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CalendarAccountSchema = exports.CalendarSchema = void 0;
3
+ exports.CalendarAccountSchema = exports.CALENDAR_SYNC_STATES = exports.CALENDAR_ACCOUNT_TYPES = exports.CalendarSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  exports.CalendarSchema = zod_1.z
6
6
  .object({
@@ -12,16 +12,20 @@ exports.CalendarSchema = zod_1.z
12
12
  isTaskCalendar: zod_1.z.boolean().optional(),
13
13
  })
14
14
  .passthrough();
15
+ /** Available calendar account provider types. */
16
+ exports.CALENDAR_ACCOUNT_TYPES = ['google', 'microsoft', 'apple'];
17
+ /** Available calendar sync states. */
18
+ exports.CALENDAR_SYNC_STATES = ['synced', 'syncing', 'error'];
15
19
  exports.CalendarAccountSchema = zod_1.z
16
20
  .object({
17
21
  id: zod_1.z.string(),
18
22
  name: zod_1.z.string(),
19
- type: zod_1.z.enum(['google', 'microsoft', 'apple']),
23
+ type: zod_1.z.enum(exports.CALENDAR_ACCOUNT_TYPES),
20
24
  isDeleted: zod_1.z.boolean().optional(),
21
25
  isEventsEnabled: zod_1.z.boolean().optional(),
22
26
  isTasksEnabled: zod_1.z.boolean().optional(),
23
27
  isAllDayTasksEnabled: zod_1.z.boolean().optional(),
24
28
  pendingOperationUntil: zod_1.z.string().nullable().optional(),
25
- calendarsSyncState: zod_1.z.enum(['synced', 'syncing', 'error']).optional(),
29
+ calendarsSyncState: zod_1.z.enum(exports.CALENDAR_SYNC_STATES).optional(),
26
30
  })
27
31
  .passthrough();
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CollaboratorStateSchema = exports.CollaboratorSchema = void 0;
3
+ exports.CollaboratorStateSchema = exports.COLLABORATOR_STATUSES = exports.CollaboratorSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const entities_1 = require("../../entities");
6
6
  exports.CollaboratorSchema = zod_1.z
@@ -12,11 +12,13 @@ exports.CollaboratorSchema = zod_1.z
12
12
  imageId: zod_1.z.string().nullable(),
13
13
  })
14
14
  .passthrough();
15
+ /** Available collaborator statuses. */
16
+ exports.COLLABORATOR_STATUSES = ['active', 'invited'];
15
17
  exports.CollaboratorStateSchema = zod_1.z
16
18
  .object({
17
19
  userId: zod_1.z.string(),
18
20
  projectId: zod_1.z.string(),
19
- state: zod_1.z.enum(['active', 'invited']),
21
+ state: zod_1.z.enum(exports.COLLABORATOR_STATUSES),
20
22
  isDeleted: zod_1.z.boolean(),
21
23
  workspaceRole: entities_1.WorkspaceRoleSchema.optional(),
22
24
  })
@@ -1,28 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ReminderSchema = exports.RelativeReminderSchema = exports.AbsoluteReminderSchema = exports.LocationReminderSchema = void 0;
3
+ exports.ReminderSchema = exports.RelativeReminderSchema = exports.AbsoluteReminderSchema = exports.LocationReminderSchema = exports.LOCATION_TRIGGERS = exports.ReminderBaseSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const entities_1 = require("../../entities");
6
- const ReminderBaseSchema = zod_1.z.object({
6
+ exports.ReminderBaseSchema = zod_1.z.object({
7
7
  id: zod_1.z.string(),
8
8
  notifyUid: zod_1.z.string(),
9
9
  itemId: zod_1.z.string(),
10
10
  projectId: zod_1.z.string().optional(),
11
11
  isDeleted: zod_1.z.boolean(),
12
12
  });
13
- exports.LocationReminderSchema = ReminderBaseSchema.extend({
13
+ /** Available location reminder triggers. */
14
+ exports.LOCATION_TRIGGERS = ['on_enter', 'on_leave'];
15
+ exports.LocationReminderSchema = exports.ReminderBaseSchema.extend({
14
16
  type: zod_1.z.literal('location'),
15
17
  name: zod_1.z.string(),
16
18
  locLat: zod_1.z.string(),
17
19
  locLong: zod_1.z.string(),
18
- locTrigger: zod_1.z.enum(['on_enter', 'on_leave']),
20
+ locTrigger: zod_1.z.enum(exports.LOCATION_TRIGGERS),
19
21
  radius: zod_1.z.number().int(),
20
22
  }).passthrough();
21
- exports.AbsoluteReminderSchema = ReminderBaseSchema.extend({
23
+ exports.AbsoluteReminderSchema = exports.ReminderBaseSchema.extend({
22
24
  type: zod_1.z.literal('absolute'),
23
25
  due: entities_1.DueDateSchema,
24
26
  }).passthrough();
25
- exports.RelativeReminderSchema = ReminderBaseSchema.extend({
27
+ exports.RelativeReminderSchema = exports.ReminderBaseSchema.extend({
26
28
  type: zod_1.z.literal('relative'),
27
29
  minuteOffset: zod_1.z.number().int(),
28
30
  due: entities_1.DueDateSchema.optional(),
@@ -1,20 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SuggestionSchema = exports.WorkspaceTemplateSuggestionSchema = exports.TemplateSuggestionSchema = void 0;
3
+ exports.SuggestionSchema = exports.SyncWorkspaceTemplateSuggestionsSchema = exports.SyncTemplateSuggestionsSchema = exports.SUGGESTION_SECTION_TYPES = exports.WorkspaceTemplateSuggestionSchema = exports.TemplateSuggestionSchema = exports.TEMPLATE_TYPES = void 0;
4
4
  const zod_1 = require("zod");
5
+ /** Available template types. */
6
+ exports.TEMPLATE_TYPES = ['project', 'setup'];
5
7
  exports.TemplateSuggestionSchema = zod_1.z
6
8
  .object({
7
9
  id: zod_1.z.string(),
8
10
  name: zod_1.z.string(),
9
- templateType: zod_1.z.enum(['project', 'setup']),
11
+ templateType: zod_1.z.enum(exports.TEMPLATE_TYPES),
10
12
  })
11
13
  .passthrough();
12
14
  exports.WorkspaceTemplateSuggestionSchema = exports.TemplateSuggestionSchema.extend({
13
15
  workspaceId: zod_1.z.string().nullable(),
14
16
  });
15
- const SyncTemplateSuggestionsSchema = zod_1.z
17
+ /** Available suggestion section types. */
18
+ exports.SUGGESTION_SECTION_TYPES = ['templates', 'most_used_user_templates'];
19
+ exports.SyncTemplateSuggestionsSchema = zod_1.z
16
20
  .object({
17
- type: zod_1.z.enum(['templates', 'most_used_user_templates']),
21
+ type: zod_1.z.enum(exports.SUGGESTION_SECTION_TYPES),
18
22
  content: zod_1.z.object({
19
23
  templates: zod_1.z.array(exports.TemplateSuggestionSchema),
20
24
  locale: zod_1.z.string(),
@@ -22,7 +26,7 @@ const SyncTemplateSuggestionsSchema = zod_1.z
22
26
  isDeleted: zod_1.z.boolean(),
23
27
  })
24
28
  .passthrough();
25
- const SyncWorkspaceTemplateSuggestionsSchema = zod_1.z
29
+ exports.SyncWorkspaceTemplateSuggestionsSchema = zod_1.z
26
30
  .object({
27
31
  type: zod_1.z.literal('most_used_workspace_templates'),
28
32
  content: zod_1.z.object({
@@ -33,6 +37,6 @@ const SyncWorkspaceTemplateSuggestionsSchema = zod_1.z
33
37
  })
34
38
  .passthrough();
35
39
  exports.SuggestionSchema = zod_1.z.union([
36
- SyncWorkspaceTemplateSuggestionsSchema,
37
- SyncTemplateSuggestionsSchema,
40
+ exports.SyncWorkspaceTemplateSuggestionsSchema,
41
+ exports.SyncTemplateSuggestionsSchema,
38
42
  ]);
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UserSettingsSchema = void 0;
3
+ exports.UserSettingsSchema = exports.QuickAddFeatureSchema = exports.NavigationFeatureSchema = void 0;
4
4
  const zod_1 = require("zod");
5
- const NavigationFeatureSchema = zod_1.z.object({
5
+ exports.NavigationFeatureSchema = zod_1.z.object({
6
6
  name: zod_1.z.string(),
7
7
  shown: zod_1.z.boolean(),
8
8
  });
9
- const QuickAddFeatureSchema = zod_1.z.object({
9
+ exports.QuickAddFeatureSchema = zod_1.z.object({
10
10
  name: zod_1.z.string(),
11
11
  shown: zod_1.z.boolean(),
12
12
  });
@@ -22,7 +22,7 @@ exports.UserSettingsSchema = zod_1.z
22
22
  navigation: zod_1.z
23
23
  .object({
24
24
  countsShown: zod_1.z.boolean(),
25
- features: zod_1.z.array(NavigationFeatureSchema),
25
+ features: zod_1.z.array(exports.NavigationFeatureSchema),
26
26
  })
27
27
  .passthrough(),
28
28
  reminderDesktop: zod_1.z.boolean(),
@@ -35,7 +35,7 @@ exports.UserSettingsSchema = zod_1.z
35
35
  quickAdd: zod_1.z
36
36
  .object({
37
37
  labelsShown: zod_1.z.boolean(),
38
- features: zod_1.z.array(QuickAddFeatureSchema),
38
+ features: zod_1.z.array(exports.QuickAddFeatureSchema),
39
39
  })
40
40
  .passthrough(),
41
41
  })
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SyncUserSchema = void 0;
3
+ exports.SyncUserSchema = exports.GettingStartedGuideProjectSchema = exports.JoinableWorkspaceSchema = exports.TzInfoSchema = exports.FeaturesSchema = void 0;
4
4
  const zod_1 = require("zod");
5
+ const entities_1 = require("../../entities");
5
6
  const user_preferences_1 = require("../user-preferences");
6
- const FeaturesSchema = zod_1.z
7
+ exports.FeaturesSchema = zod_1.z
7
8
  .object({
8
9
  karmaDisabled: zod_1.z.boolean(),
9
10
  restriction: zod_1.z.number().int(),
@@ -17,7 +18,7 @@ const FeaturesSchema = zod_1.z
17
18
  migratedFromTdb: zod_1.z.boolean().optional(),
18
19
  })
19
20
  .passthrough();
20
- const TzInfoSchema = zod_1.z
21
+ exports.TzInfoSchema = zod_1.z
21
22
  .object({
22
23
  timezone: zod_1.z.string(),
23
24
  hours: zod_1.z.number().int(),
@@ -26,14 +27,14 @@ const TzInfoSchema = zod_1.z
26
27
  gmtString: zod_1.z.string(),
27
28
  })
28
29
  .passthrough();
29
- const JoinableWorkspaceSchema = zod_1.z
30
+ exports.JoinableWorkspaceSchema = zod_1.z
30
31
  .object({
31
32
  workspaceId: zod_1.z.string(),
32
33
  workspaceName: zod_1.z.string(),
33
34
  memberCount: zod_1.z.number().int(),
34
35
  })
35
36
  .passthrough();
36
- const GettingStartedGuideProjectSchema = zod_1.z
37
+ exports.GettingStartedGuideProjectSchema = zod_1.z
37
38
  .object({
38
39
  onboardingUseCase: zod_1.z.string(),
39
40
  projectId: zod_1.z.string(),
@@ -64,7 +65,7 @@ exports.SyncUserSchema = zod_1.z
64
65
  dateistLang: zod_1.z.string().nullable(),
65
66
  daysOff: zod_1.z.array(zod_1.z.number().int()),
66
67
  featureIdentifier: zod_1.z.string(),
67
- features: FeaturesSchema,
68
+ features: exports.FeaturesSchema,
68
69
  freeTrailExpires: zod_1.z.string().optional(),
69
70
  hasMagicNumber: zod_1.z.boolean(),
70
71
  hasPassword: zod_1.z.boolean(),
@@ -73,9 +74,9 @@ exports.SyncUserSchema = zod_1.z
73
74
  inboxProjectId: zod_1.z.string(),
74
75
  isCelebrationsEnabled: zod_1.z.boolean(),
75
76
  isPremium: zod_1.z.boolean(),
76
- joinableWorkspace: JoinableWorkspaceSchema.nullable(),
77
+ joinableWorkspace: exports.JoinableWorkspaceSchema.nullable(),
77
78
  joinedAt: zod_1.z.string(),
78
- gettingStartedGuideProjects: zod_1.z.array(GettingStartedGuideProjectSchema).nullable(),
79
+ gettingStartedGuideProjects: zod_1.z.array(exports.GettingStartedGuideProjectSchema).nullable(),
79
80
  karma: zod_1.z.number(),
80
81
  karmaTrend: zod_1.z.string(),
81
82
  lang: zod_1.z.string(),
@@ -91,12 +92,7 @@ exports.SyncUserSchema = zod_1.z
91
92
  onboardingSkipped: zod_1.z.boolean().optional(),
92
93
  onboardingTeamMode: zod_1.z.boolean().nullable().optional(),
93
94
  onboardingUseCases: zod_1.z.array(zod_1.z.string()).nullable().optional(),
94
- premiumStatus: zod_1.z.enum([
95
- 'not_premium',
96
- 'current_personal_plan',
97
- 'legacy_personal_plan',
98
- 'teams_business_member',
99
- ]),
95
+ premiumStatus: zod_1.z.enum(entities_1.PREMIUM_STATUSES),
100
96
  premiumUntil: zod_1.z.string().nullable(),
101
97
  rambleSessionsUsage: zod_1.z
102
98
  .object({
@@ -114,7 +110,7 @@ exports.SyncUserSchema = zod_1.z
114
110
  themeId: zod_1.z.string(),
115
111
  timeFormat: user_preferences_1.TimeFormatSchema,
116
112
  token: zod_1.z.string(),
117
- tzInfo: TzInfoSchema,
113
+ tzInfo: exports.TzInfoSchema,
118
114
  uniquePrefix: zod_1.z.number().int(),
119
115
  verificationStatus: zod_1.z.string(),
120
116
  websocketUrl: zod_1.z.string(),
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ProjectViewOptionsDefaultsSchema = exports.ViewOptionsSchema = void 0;
3
+ exports.ProjectViewOptionsDefaultsSchema = exports.ViewOptionsSchema = exports.CalendarSettingsSchema = exports.CALENDAR_LAYOUTS = exports.SortOrderSchema = exports.SORT_ORDERS = exports.SortedBySchema = exports.SORTED_BY_OPTIONS = exports.GroupedBySchema = exports.GROUPED_BY_OPTIONS = exports.ViewModeSchema = exports.VIEW_MODES = exports.ViewTypeSchema = exports.VIEW_TYPES = void 0;
4
4
  const zod_1 = require("zod");
5
- const ViewTypeSchema = zod_1.z.enum([
5
+ /** Available view types. */
6
+ exports.VIEW_TYPES = [
6
7
  'TODAY',
7
8
  'UPCOMING',
8
9
  'PROJECT',
@@ -16,10 +17,13 @@ const ViewTypeSchema = zod_1.z.enum([
16
17
  'ASSIGNED',
17
18
  'OVERDUE',
18
19
  'WORKSPACE_OVERVIEW',
19
- ]);
20
- const ViewModeSchema = zod_1.z.enum(['LIST', 'BOARD', 'CALENDAR']);
21
- const GroupedBySchema = zod_1.z
22
- .enum([
20
+ ];
21
+ exports.ViewTypeSchema = zod_1.z.enum(exports.VIEW_TYPES);
22
+ /** Available view modes. */
23
+ exports.VIEW_MODES = ['LIST', 'BOARD', 'CALENDAR'];
24
+ exports.ViewModeSchema = zod_1.z.enum(exports.VIEW_MODES);
25
+ /** Available grouping options. */
26
+ exports.GROUPED_BY_OPTIONS = [
23
27
  'ASSIGNEE',
24
28
  'ADDED_DATE',
25
29
  'DUE_DATE',
@@ -28,10 +32,10 @@ const GroupedBySchema = zod_1.z
28
32
  'PRIORITY',
29
33
  'PROJECT',
30
34
  'WORKSPACE',
31
- ])
32
- .nullable();
33
- const SortedBySchema = zod_1.z
34
- .enum([
35
+ ];
36
+ exports.GroupedBySchema = zod_1.z.enum(exports.GROUPED_BY_OPTIONS).nullable();
37
+ /** Available sorting options. */
38
+ exports.SORTED_BY_OPTIONS = [
35
39
  'MANUAL',
36
40
  'ALPHABETICALLY',
37
41
  'ASSIGNEE',
@@ -41,35 +45,39 @@ const SortedBySchema = zod_1.z
41
45
  'PRIORITY',
42
46
  'PROJECT',
43
47
  'WORKSPACE',
44
- ])
45
- .nullable();
46
- const SortOrderSchema = zod_1.z.enum(['ASC', 'DESC']).nullable();
47
- const CalendarSettingsSchema = zod_1.z
48
+ ];
49
+ exports.SortedBySchema = zod_1.z.enum(exports.SORTED_BY_OPTIONS).nullable();
50
+ /** Available sort directions. */
51
+ exports.SORT_ORDERS = ['ASC', 'DESC'];
52
+ exports.SortOrderSchema = zod_1.z.enum(exports.SORT_ORDERS).nullable();
53
+ /** Available calendar layout modes. */
54
+ exports.CALENDAR_LAYOUTS = ['WEEK', 'MONTH'];
55
+ exports.CalendarSettingsSchema = zod_1.z
48
56
  .object({
49
- layout: zod_1.z.enum(['WEEK', 'MONTH']).optional(),
57
+ layout: zod_1.z.enum(exports.CALENDAR_LAYOUTS).optional(),
50
58
  })
51
59
  .passthrough();
52
60
  exports.ViewOptionsSchema = zod_1.z
53
61
  .object({
54
- viewType: ViewTypeSchema,
62
+ viewType: exports.ViewTypeSchema,
55
63
  objectId: zod_1.z.string().optional(),
56
- groupedBy: GroupedBySchema.optional(),
64
+ groupedBy: exports.GroupedBySchema.optional(),
57
65
  filteredBy: zod_1.z.string().nullable().optional(),
58
- viewMode: ViewModeSchema.optional(),
66
+ viewMode: exports.ViewModeSchema.optional(),
59
67
  showCompletedTasks: zod_1.z.boolean().optional(),
60
- sortedBy: SortedBySchema.optional(),
61
- sortOrder: SortOrderSchema.optional(),
68
+ sortedBy: exports.SortedBySchema.optional(),
69
+ sortOrder: exports.SortOrderSchema.optional(),
62
70
  })
63
71
  .passthrough();
64
72
  exports.ProjectViewOptionsDefaultsSchema = zod_1.z
65
73
  .object({
66
74
  projectId: zod_1.z.string(),
67
- viewMode: ViewModeSchema.nullable().optional(),
68
- groupedBy: GroupedBySchema.optional(),
69
- sortedBy: SortedBySchema.optional(),
70
- sortOrder: SortOrderSchema.optional(),
75
+ viewMode: exports.ViewModeSchema.nullable().optional(),
76
+ groupedBy: exports.GroupedBySchema.optional(),
77
+ sortedBy: exports.SortedBySchema.optional(),
78
+ sortOrder: exports.SortOrderSchema.optional(),
71
79
  showCompletedTasks: zod_1.z.boolean().optional(),
72
80
  filteredBy: zod_1.z.string().nullable().optional(),
73
- calendarSettings: CalendarSettingsSchema.nullable().optional(),
81
+ calendarSettings: exports.CalendarSettingsSchema.nullable().optional(),
74
82
  })
75
83
  .passthrough();