@doist/todoist-api-typescript 7.2.0 → 7.4.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 (55) hide show
  1. package/dist/cjs/authentication.js +10 -0
  2. package/dist/cjs/rest-client.js +1 -1
  3. package/dist/cjs/test-utils/asserts.js +1 -1
  4. package/dist/cjs/test-utils/msw-setup.js +4 -3
  5. package/dist/cjs/todoist-api.js +6 -6
  6. package/dist/cjs/types/entities.js +45 -26
  7. package/dist/cjs/types/errors.js +0 -1
  8. package/dist/cjs/types/sync/commands/labels.js +3 -0
  9. package/dist/cjs/types/sync/commands/shared.js +21 -0
  10. package/dist/cjs/types/sync/resources/calendars.js +7 -3
  11. package/dist/cjs/types/sync/resources/collaborators.js +4 -2
  12. package/dist/cjs/types/sync/resources/reminders.js +8 -6
  13. package/dist/cjs/types/sync/resources/suggestions.js +11 -7
  14. package/dist/cjs/types/sync/resources/user-settings.js +5 -5
  15. package/dist/cjs/types/sync/resources/user.js +11 -15
  16. package/dist/cjs/types/sync/resources/view-options.js +33 -25
  17. package/dist/cjs/types/sync/user-preferences.js +27 -7
  18. package/dist/cjs/utils/sanitization.js +7 -7
  19. package/dist/esm/authentication.js +9 -0
  20. package/dist/esm/rest-client.js +1 -1
  21. package/dist/esm/test-utils/asserts.js +1 -1
  22. package/dist/esm/test-utils/msw-setup.js +1 -0
  23. package/dist/esm/todoist-api.js +6 -6
  24. package/dist/esm/types/entities.js +34 -15
  25. package/dist/esm/types/errors.js +0 -1
  26. package/dist/esm/types/sync/commands/labels.js +2 -1
  27. package/dist/esm/types/sync/commands/shared.js +20 -1
  28. package/dist/esm/types/sync/resources/calendars.js +6 -2
  29. package/dist/esm/types/sync/resources/collaborators.js +3 -1
  30. package/dist/esm/types/sync/resources/reminders.js +4 -2
  31. package/dist/esm/types/sync/resources/suggestions.js +8 -4
  32. package/dist/esm/types/sync/resources/user-settings.js +2 -2
  33. package/dist/esm/types/sync/resources/user.js +6 -10
  34. package/dist/esm/types/sync/resources/view-options.js +22 -14
  35. package/dist/esm/types/sync/user-preferences.js +23 -3
  36. package/dist/esm/utils/sanitization.js +7 -7
  37. package/dist/types/authentication.d.ts +5 -3
  38. package/dist/types/types/entities.d.ts +52 -2
  39. package/dist/types/types/sync/commands/labels.d.ts +5 -1
  40. package/dist/types/types/sync/commands/project-view-options.d.ts +2 -2
  41. package/dist/types/types/sync/commands/reminders.d.ts +3 -2
  42. package/dist/types/types/sync/commands/shared.d.ts +12 -4
  43. package/dist/types/types/sync/commands/view-options.d.ts +3 -7
  44. package/dist/types/types/sync/resources/calendars.d.ts +8 -0
  45. package/dist/types/types/sync/resources/collaborators.d.ts +4 -0
  46. package/dist/types/types/sync/resources/reminders.d.ts +11 -0
  47. package/dist/types/types/sync/resources/suggestions.d.ts +42 -0
  48. package/dist/types/types/sync/resources/user-settings.d.ts +8 -0
  49. package/dist/types/types/sync/resources/user.d.ts +32 -2
  50. package/dist/types/types/sync/resources/view-options.d.ts +75 -0
  51. package/dist/types/types/sync/user-preferences.d.ts +30 -4
  52. package/package.json +10 -17
  53. package/dist/cjs/test-utils/mocks.js +0 -3
  54. package/dist/esm/test-utils/mocks.js +0 -3
  55. package/dist/types/test-utils/mocks.d.ts +0 -0
@@ -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();
@@ -1,10 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DayOfWeekSchema = exports.TimeFormatSchema = exports.DateFormatSchema = exports.BooleanFromZeroOneSchema = exports.DAY_OF_WEEK_TO_API = exports.TIME_FORMAT_TO_API = exports.DATE_FORMAT_TO_API = void 0;
3
+ exports.DayOfWeekSchema = exports.TimeFormatSchema = exports.DateFormatSchema = exports.BooleanFromZeroOneSchema = exports.DAY_OF_WEEK_TO_API = exports.TIME_FORMAT_TO_API = exports.DATE_FORMAT_TO_API = exports.DAY_OF_WEEK_FROM_API = exports.TIME_FORMAT_FROM_API = exports.DATE_FORMAT_FROM_API = exports.DAYS_OF_WEEK = exports.TIME_FORMATS = exports.DATE_FORMATS = void 0;
4
4
  const zod_1 = require("zod");
5
- const DATE_FORMAT_FROM_API = { 0: 'DD/MM/YYYY', 1: 'MM/DD/YYYY' };
6
- const TIME_FORMAT_FROM_API = { 0: '24h', 1: '12h' };
7
- const DAY_OF_WEEK_FROM_API = {
5
+ /** Available date format options. */
6
+ exports.DATE_FORMATS = ['DD/MM/YYYY', 'MM/DD/YYYY'];
7
+ /** Available time format options. */
8
+ exports.TIME_FORMATS = ['24h', '12h'];
9
+ /** Available days of the week. */
10
+ exports.DAYS_OF_WEEK = [
11
+ 'Monday',
12
+ 'Tuesday',
13
+ 'Wednesday',
14
+ 'Thursday',
15
+ 'Friday',
16
+ 'Saturday',
17
+ 'Sunday',
18
+ ];
19
+ exports.DATE_FORMAT_FROM_API = {
20
+ 0: 'DD/MM/YYYY',
21
+ 1: 'MM/DD/YYYY',
22
+ };
23
+ exports.TIME_FORMAT_FROM_API = {
24
+ 0: '24h',
25
+ 1: '12h',
26
+ };
27
+ exports.DAY_OF_WEEK_FROM_API = {
8
28
  1: 'Monday',
9
29
  2: 'Tuesday',
10
30
  3: 'Wednesday',
@@ -34,10 +54,10 @@ exports.BooleanFromZeroOneSchema = zod_1.z
34
54
  /** Zod read-schemas: parse API numbers, emit descriptive strings */
35
55
  exports.DateFormatSchema = zod_1.z
36
56
  .union([zod_1.z.literal(0), zod_1.z.literal(1)])
37
- .transform((v) => DATE_FORMAT_FROM_API[v]);
57
+ .transform((v) => exports.DATE_FORMAT_FROM_API[v]);
38
58
  exports.TimeFormatSchema = zod_1.z
39
59
  .union([zod_1.z.literal(0), zod_1.z.literal(1)])
40
- .transform((v) => TIME_FORMAT_FROM_API[v]);
60
+ .transform((v) => exports.TIME_FORMAT_FROM_API[v]);
41
61
  exports.DayOfWeekSchema = zod_1.z
42
62
  .union([
43
63
  zod_1.z.literal(1),
@@ -48,4 +68,4 @@ exports.DayOfWeekSchema = zod_1.z
48
68
  zod_1.z.literal(6),
49
69
  zod_1.z.literal(7),
50
70
  ])
51
- .transform((v) => DAY_OF_WEEK_FROM_API[v]);
71
+ .transform((v) => exports.DAY_OF_WEEK_FROM_API[v]);
@@ -18,7 +18,7 @@ function removeStyleFormatting(input) {
18
18
  if (!input.includes('!') && !input.includes('*') && !input.includes('_')) {
19
19
  return input;
20
20
  }
21
- function removeMarkdown(match, prefix, text) {
21
+ function removeMarkdown(_match, prefix, text) {
22
22
  return `${prefix}${text}`;
23
23
  }
24
24
  input = input.replace(BOLD_ITALIC_FORMAT, removeMarkdown);
@@ -27,7 +27,7 @@ function removeStyleFormatting(input) {
27
27
  return input;
28
28
  }
29
29
  function removeCodeFormatting(input) {
30
- function removeMarkdown(match, text) {
30
+ function removeMarkdown(_match, text) {
31
31
  return text;
32
32
  }
33
33
  input = input.replace(CODE_BLOCK_FORMAT, removeMarkdown);
@@ -47,7 +47,7 @@ function removeMarkdownLinks(input) {
47
47
  if (!input.includes('[') || !input.includes(']')) {
48
48
  return input;
49
49
  }
50
- function removeMarkdown(match, text) {
50
+ function removeMarkdown(_match, text) {
51
51
  return text;
52
52
  }
53
53
  return input.replace(MARKDOWN_LINK, removeMarkdown);
@@ -56,20 +56,20 @@ function removeTodoistLinks(input) {
56
56
  if (!input.includes('(') || !input.includes(')')) {
57
57
  return input;
58
58
  }
59
- function removeMarkdown(match, url, text) {
59
+ function removeMarkdown(_match, _url, text) {
60
60
  return text;
61
61
  }
62
62
  return input.replace(TODOIST_LINK, removeMarkdown);
63
63
  }
64
64
  function removeAppLinks(input) {
65
65
  if (input.includes('gmail')) {
66
- input = input.replace(GMAIL_LINK, (match, id, text) => text);
66
+ input = input.replace(GMAIL_LINK, (_match, _id, text) => text);
67
67
  }
68
68
  if (input.includes('outlook')) {
69
- input = input.replace(OUTLOOK_LINK, (match, id, text) => text);
69
+ input = input.replace(OUTLOOK_LINK, (_match, _id, text) => text);
70
70
  }
71
71
  if (input.includes('thunderbird')) {
72
- input = input.replace(THUNDERBIRD_LINK, (match, text) => text);
72
+ input = input.replace(THUNDERBIRD_LINK, (_match, text) => text);
73
73
  }
74
74
  return input;
75
75
  }
@@ -2,6 +2,15 @@ import { request, isSuccess } from './rest-client.js';
2
2
  import { v4 as uuid } from 'uuid';
3
3
  import { TodoistRequestError } from './types/index.js';
4
4
  import { getAuthBaseUri, getSyncBaseUri, ENDPOINT_AUTHORIZATION, ENDPOINT_GET_TOKEN, ENDPOINT_REVOKE, } from './consts/endpoints.js';
5
+ /** Available OAuth2 permission scopes. */
6
+ export const PERMISSIONS = [
7
+ 'task:add',
8
+ 'data:read',
9
+ 'data:read_write',
10
+ 'data:delete',
11
+ 'project:delete',
12
+ 'backups:read',
13
+ ];
5
14
  /**
6
15
  * Creates a Basic Authentication header value from client credentials.
7
16
  * @param clientId - The OAuth client ID
@@ -8,7 +8,7 @@ export function paramsSerializer(params) {
8
8
  const qs = new URLSearchParams();
9
9
  Object.keys(params).forEach((key) => {
10
10
  const value = params[key];
11
- if (value != null) {
11
+ if (value !== null && value !== undefined) {
12
12
  if (Array.isArray(value)) {
13
13
  qs.append(key, JSON.stringify(value));
14
14
  }
@@ -1,5 +1,5 @@
1
1
  // Has to use 'any' to express constructor type
2
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2
+ // oxlint-disable-next-line no-explicit-any
3
3
  export function assertInstance(value, type) {
4
4
  if (value instanceof type) {
5
5
  return;
@@ -1,3 +1,4 @@
1
+ import { beforeAll, afterEach, afterAll } from 'vitest';
1
2
  import { setupServer } from 'msw/node';
2
3
  import { http, HttpResponse } from 'msw';
3
4
  // Request capture storage
@@ -846,7 +846,7 @@ export class TodoistApi {
846
846
  * @returns A promise that resolves to an array of labels.
847
847
  */
848
848
  async getLabels(args = {}) {
849
- const { data: { results, nextCursor: nextCursor }, } = await request({
849
+ const { data: { results, nextCursor }, } = await request({
850
850
  httpMethod: 'GET',
851
851
  baseUri: this.syncApiBase,
852
852
  relativePath: ENDPOINT_REST_LABELS,
@@ -945,7 +945,7 @@ export class TodoistApi {
945
945
  * @returns A promise that resolves to an array of shared labels.
946
946
  */
947
947
  async getSharedLabels(args) {
948
- const { data: { results, nextCursor: nextCursor }, } = await request({
948
+ const { data: { results, nextCursor }, } = await request({
949
949
  httpMethod: 'GET',
950
950
  baseUri: this.syncApiBase,
951
951
  relativePath: ENDPOINT_REST_LABELS_SHARED,
@@ -1571,10 +1571,10 @@ export class TodoistApi {
1571
1571
  payload: queryParams,
1572
1572
  requestId: requestId,
1573
1573
  });
1574
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
1574
+ // oxlint-disable-next-line no-unsafe-assignment, no-unsafe-call, no-unsafe-member-access
1575
1575
  const validatedProjects = (_a = response.data.results) === null || _a === void 0 ? void 0 : _a.map((project) => validateProject(project));
1576
1576
  return Object.assign(Object.assign({}, response.data), {
1577
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
1577
+ // oxlint-disable-next-line no-unsafe-assignment
1578
1578
  results: validatedProjects || [] });
1579
1579
  }
1580
1580
  /**
@@ -1602,10 +1602,10 @@ export class TodoistApi {
1602
1602
  payload: queryParams,
1603
1603
  requestId: requestId,
1604
1604
  });
1605
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
1605
+ // oxlint-disable-next-line no-unsafe-assignment, no-unsafe-call, no-unsafe-member-access
1606
1606
  const validatedProjects = (_a = response.data.results) === null || _a === void 0 ? void 0 : _a.map((project) => validateProject(project));
1607
1607
  return Object.assign(Object.assign({}, response.data), {
1608
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
1608
+ // oxlint-disable-next-line no-unsafe-assignment
1609
1609
  results: validatedProjects || [] });
1610
1610
  }
1611
1611
  }
@@ -23,9 +23,11 @@ export const DueDateSchema = z
23
23
  timezone: z.string().nullable().optional(),
24
24
  lang: z.string().nullable().optional(),
25
25
  });
26
+ /** Available duration units for task deadlines. */
27
+ export const DURATION_UNITS = ['minute', 'day'];
26
28
  export const DurationSchema = z.object({
27
29
  amount: z.number().positive('Value should be greater than zero'),
28
- unit: z.enum(['minute', 'day']),
30
+ unit: z.enum(DURATION_UNITS),
29
31
  });
30
32
  export const DeadlineSchema = z.object({
31
33
  date: z.string(),
@@ -94,7 +96,9 @@ export const PersonalProjectSchema = BaseProjectSchema.extend({
94
96
  }).transform((data) => {
95
97
  return Object.assign(Object.assign({}, data), { url: getProjectUrl(data.id, data.name) });
96
98
  });
97
- export const ProjectVisibilitySchema = z.enum(['restricted', 'team', 'public']);
99
+ /** Available project visibility levels. */
100
+ export const PROJECT_VISIBILITIES = ['restricted', 'team', 'public'];
101
+ export const ProjectVisibilitySchema = z.enum(PROJECT_VISIBILITIES);
98
102
  /**
99
103
  * Schema for workspace projects in Todoist.
100
104
  */
@@ -110,6 +114,8 @@ export const WorkspaceProjectSchema = BaseProjectSchema.extend({
110
114
  }).transform((data) => {
111
115
  return Object.assign(Object.assign({}, data), { url: getProjectUrl(data.id, data.name) });
112
116
  });
117
+ /** Available project view styles. */
118
+ export const PROJECT_VIEW_STYLES = ['list', 'board', 'calendar'];
113
119
  export const SectionSchema = z
114
120
  .object({
115
121
  id: z.string(),
@@ -134,6 +140,8 @@ export const LabelSchema = z.object({
134
140
  color: z.string(),
135
141
  isFavorite: z.boolean(),
136
142
  });
143
+ /** Available file attachment upload states. */
144
+ export const UPLOAD_STATES = ['pending', 'completed'];
137
145
  export const AttachmentSchema = z
138
146
  .object({
139
147
  resourceType: z.string(),
@@ -144,7 +152,7 @@ export const AttachmentSchema = z
144
152
  fileType: z.string().nullable().optional(),
145
153
  fileUrl: z.string().nullable().optional(),
146
154
  fileDuration: z.number().int().nullable().optional(),
147
- uploadState: z.enum(['pending', 'completed']).nullable().optional(),
155
+ uploadState: z.enum(UPLOAD_STATES).nullable().optional(),
148
156
  image: z.string().nullable().optional(),
149
157
  imageWidth: z.number().int().nullable().optional(),
150
158
  imageHeight: z.number().int().nullable().optional(),
@@ -189,6 +197,13 @@ export const TimezoneInfoSchema = z.object({
189
197
  minutes: z.number().int(),
190
198
  timezone: z.string(),
191
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
+ ];
192
207
  export const CurrentUserSchema = z.object({
193
208
  id: z.string(),
194
209
  email: z.string(),
@@ -199,12 +214,7 @@ export const CurrentUserSchema = z.object({
199
214
  avatarSmall: z.string().nullish(),
200
215
  businessAccountId: z.string().nullable(),
201
216
  isPremium: z.boolean(),
202
- premiumStatus: z.enum([
203
- 'not_premium',
204
- 'current_personal_plan',
205
- 'legacy_personal_plan',
206
- 'teams_business_member',
207
- ]),
217
+ premiumStatus: z.enum(PREMIUM_STATUSES),
208
218
  dateFormat: z.number().int(),
209
219
  timeFormat: z.number().int(),
210
220
  weeklyGoal: z.number().int(),
@@ -222,20 +232,20 @@ export const CurrentUserSchema = z.object({
222
232
  daysOff: z.array(z.number().int()),
223
233
  weekendStartDay: z.number().int(),
224
234
  });
225
- const StreakSchema = z.object({
235
+ export const StreakSchema = z.object({
226
236
  count: z.number(),
227
237
  start: z.string(),
228
238
  end: z.string(),
229
239
  });
230
- const CompletedItemSchema = z.object({
240
+ export const CompletedItemSchema = z.object({
231
241
  id: z.string(),
232
242
  completed: z.number(),
233
243
  });
234
- const ItemsWithDateSchema = z.object({
244
+ export const ItemsWithDateSchema = z.object({
235
245
  items: z.array(CompletedItemSchema),
236
246
  totalCompleted: z.number(),
237
247
  });
238
- const KarmaUpdateSchema = z.object({
248
+ export const KarmaUpdateSchema = z.object({
239
249
  time: z.string(),
240
250
  newKarma: z.number(),
241
251
  positiveKarma: z.number(),
@@ -343,10 +353,19 @@ export const FormattedPriceListingSchema = z.object({
343
353
  interval: z.string().optional(),
344
354
  formatted: z.string().optional(),
345
355
  });
356
+ /** Available workspace plan names. */
357
+ export const WORKSPACE_CURRENT_PLANS = ['Business', 'Starter'];
358
+ /** Available workspace plan statuses. */
359
+ export const WORKSPACE_PLAN_STATUSES = [
360
+ 'Active',
361
+ 'Downgraded',
362
+ 'Cancelled',
363
+ 'NeverSubscribed',
364
+ ];
346
365
  export const WorkspacePlanDetailsSchema = z.object({
347
366
  currentMemberCount: z.number(),
348
- currentPlan: z.enum(['Business', 'Starter']),
349
- currentPlanStatus: z.enum(['Active', 'Downgraded', 'Cancelled', 'NeverSubscribed']),
367
+ currentPlan: z.enum(WORKSPACE_CURRENT_PLANS),
368
+ currentPlanStatus: z.enum(WORKSPACE_PLAN_STATUSES),
350
369
  downgradeAt: z.string().nullable(),
351
370
  currentActiveProjects: z.number(),
352
371
  maximumActiveProjects: z.number(),
@@ -1,7 +1,6 @@
1
1
  import { CustomError } from 'ts-custom-error';
2
2
  const authenticationErrorCodes = [401, 403];
3
3
  export class TodoistRequestError extends CustomError {
4
- // eslint-disable-next-line max-params
5
4
  constructor(message, httpStatusCode, responseData) {
6
5
  super(message);
7
6
  this.message = message;
@@ -1 +1,2 @@
1
- export {};
1
+ /** Available label delete cascade modes. */
2
+ export const LABEL_DELETE_CASCADE_MODES = ['none', 'all'];
@@ -1,4 +1,23 @@
1
1
  /**
2
2
  * Shared types used across multiple Sync API command argument types.
3
3
  */
4
- export {};
4
+ /** Available project workflow statuses. */
5
+ export const PROJECT_STATUSES = [
6
+ 'PLANNED',
7
+ 'IN_PROGRESS',
8
+ 'PAUSED',
9
+ 'COMPLETED',
10
+ 'CANCELED',
11
+ ];
12
+ /** Available default collaborator roles. */
13
+ export const COLLABORATOR_ROLES = [
14
+ 'CREATOR',
15
+ 'ADMIN',
16
+ 'READ_WRITE',
17
+ 'EDIT_ONLY',
18
+ 'COMPLETE_ONLY',
19
+ ];
20
+ /** Available reminder notification services. */
21
+ export const REMINDER_SERVICES = ['default', 'email', 'mobile', 'push', 'no_default'];
22
+ /** Available workspace project sort orders. */
23
+ export const WORKSPACE_PROJECT_SORT_ORDERS = ['MANUAL', 'A_TO_Z', 'Z_TO_A'];
@@ -9,16 +9,20 @@ export const CalendarSchema = z
9
9
  isTaskCalendar: z.boolean().optional(),
10
10
  })
11
11
  .passthrough();
12
+ /** Available calendar account provider types. */
13
+ export const CALENDAR_ACCOUNT_TYPES = ['google', 'microsoft', 'apple'];
14
+ /** Available calendar sync states. */
15
+ export const CALENDAR_SYNC_STATES = ['synced', 'syncing', 'error'];
12
16
  export const CalendarAccountSchema = z
13
17
  .object({
14
18
  id: z.string(),
15
19
  name: z.string(),
16
- type: z.enum(['google', 'microsoft', 'apple']),
20
+ type: z.enum(CALENDAR_ACCOUNT_TYPES),
17
21
  isDeleted: z.boolean().optional(),
18
22
  isEventsEnabled: z.boolean().optional(),
19
23
  isTasksEnabled: z.boolean().optional(),
20
24
  isAllDayTasksEnabled: z.boolean().optional(),
21
25
  pendingOperationUntil: z.string().nullable().optional(),
22
- calendarsSyncState: z.enum(['synced', 'syncing', 'error']).optional(),
26
+ calendarsSyncState: z.enum(CALENDAR_SYNC_STATES).optional(),
23
27
  })
24
28
  .passthrough();
@@ -9,11 +9,13 @@ export const CollaboratorSchema = z
9
9
  imageId: z.string().nullable(),
10
10
  })
11
11
  .passthrough();
12
+ /** Available collaborator statuses. */
13
+ export const COLLABORATOR_STATUSES = ['active', 'invited'];
12
14
  export const CollaboratorStateSchema = z
13
15
  .object({
14
16
  userId: z.string(),
15
17
  projectId: z.string(),
16
- state: z.enum(['active', 'invited']),
18
+ state: z.enum(COLLABORATOR_STATUSES),
17
19
  isDeleted: z.boolean(),
18
20
  workspaceRole: WorkspaceRoleSchema.optional(),
19
21
  })
@@ -1,18 +1,20 @@
1
1
  import { z } from 'zod';
2
2
  import { DueDateSchema } from '../../entities.js';
3
- const ReminderBaseSchema = z.object({
3
+ export const ReminderBaseSchema = z.object({
4
4
  id: z.string(),
5
5
  notifyUid: z.string(),
6
6
  itemId: z.string(),
7
7
  projectId: z.string().optional(),
8
8
  isDeleted: z.boolean(),
9
9
  });
10
+ /** Available location reminder triggers. */
11
+ export const LOCATION_TRIGGERS = ['on_enter', 'on_leave'];
10
12
  export const LocationReminderSchema = ReminderBaseSchema.extend({
11
13
  type: z.literal('location'),
12
14
  name: z.string(),
13
15
  locLat: z.string(),
14
16
  locLong: z.string(),
15
- locTrigger: z.enum(['on_enter', 'on_leave']),
17
+ locTrigger: z.enum(LOCATION_TRIGGERS),
16
18
  radius: z.number().int(),
17
19
  }).passthrough();
18
20
  export const AbsoluteReminderSchema = ReminderBaseSchema.extend({
@@ -1,17 +1,21 @@
1
1
  import { z } from 'zod';
2
+ /** Available template types. */
3
+ export const TEMPLATE_TYPES = ['project', 'setup'];
2
4
  export const TemplateSuggestionSchema = z
3
5
  .object({
4
6
  id: z.string(),
5
7
  name: z.string(),
6
- templateType: z.enum(['project', 'setup']),
8
+ templateType: z.enum(TEMPLATE_TYPES),
7
9
  })
8
10
  .passthrough();
9
11
  export const WorkspaceTemplateSuggestionSchema = TemplateSuggestionSchema.extend({
10
12
  workspaceId: z.string().nullable(),
11
13
  });
12
- const SyncTemplateSuggestionsSchema = z
14
+ /** Available suggestion section types. */
15
+ export const SUGGESTION_SECTION_TYPES = ['templates', 'most_used_user_templates'];
16
+ export const SyncTemplateSuggestionsSchema = z
13
17
  .object({
14
- type: z.enum(['templates', 'most_used_user_templates']),
18
+ type: z.enum(SUGGESTION_SECTION_TYPES),
15
19
  content: z.object({
16
20
  templates: z.array(TemplateSuggestionSchema),
17
21
  locale: z.string(),
@@ -19,7 +23,7 @@ const SyncTemplateSuggestionsSchema = z
19
23
  isDeleted: z.boolean(),
20
24
  })
21
25
  .passthrough();
22
- const SyncWorkspaceTemplateSuggestionsSchema = z
26
+ export const SyncWorkspaceTemplateSuggestionsSchema = z
23
27
  .object({
24
28
  type: z.literal('most_used_workspace_templates'),
25
29
  content: z.object({
@@ -1,9 +1,9 @@
1
1
  import { z } from 'zod';
2
- const NavigationFeatureSchema = z.object({
2
+ export const NavigationFeatureSchema = z.object({
3
3
  name: z.string(),
4
4
  shown: z.boolean(),
5
5
  });
6
- const QuickAddFeatureSchema = z.object({
6
+ export const QuickAddFeatureSchema = z.object({
7
7
  name: z.string(),
8
8
  shown: z.boolean(),
9
9
  });
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod';
2
+ import { PREMIUM_STATUSES } from '../../entities.js';
2
3
  import { BooleanFromZeroOneSchema, DateFormatSchema, DayOfWeekSchema, TimeFormatSchema, } from '../user-preferences.js';
3
- const FeaturesSchema = z
4
+ export const FeaturesSchema = z
4
5
  .object({
5
6
  karmaDisabled: z.boolean(),
6
7
  restriction: z.number().int(),
@@ -14,7 +15,7 @@ const FeaturesSchema = z
14
15
  migratedFromTdb: z.boolean().optional(),
15
16
  })
16
17
  .passthrough();
17
- const TzInfoSchema = z
18
+ export const TzInfoSchema = z
18
19
  .object({
19
20
  timezone: z.string(),
20
21
  hours: z.number().int(),
@@ -23,14 +24,14 @@ const TzInfoSchema = z
23
24
  gmtString: z.string(),
24
25
  })
25
26
  .passthrough();
26
- const JoinableWorkspaceSchema = z
27
+ export const JoinableWorkspaceSchema = z
27
28
  .object({
28
29
  workspaceId: z.string(),
29
30
  workspaceName: z.string(),
30
31
  memberCount: z.number().int(),
31
32
  })
32
33
  .passthrough();
33
- const GettingStartedGuideProjectSchema = z
34
+ export const GettingStartedGuideProjectSchema = z
34
35
  .object({
35
36
  onboardingUseCase: z.string(),
36
37
  projectId: z.string(),
@@ -88,12 +89,7 @@ export const SyncUserSchema = z
88
89
  onboardingSkipped: z.boolean().optional(),
89
90
  onboardingTeamMode: z.boolean().nullable().optional(),
90
91
  onboardingUseCases: z.array(z.string()).nullable().optional(),
91
- premiumStatus: z.enum([
92
- 'not_premium',
93
- 'current_personal_plan',
94
- 'legacy_personal_plan',
95
- 'teams_business_member',
96
- ]),
92
+ premiumStatus: z.enum(PREMIUM_STATUSES),
97
93
  premiumUntil: z.string().nullable(),
98
94
  rambleSessionsUsage: z
99
95
  .object({