@doist/todoist-sdk 14.1.0 → 15.0.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 (172) hide show
  1. package/README.md +46 -1
  2. package/dist/esm/index.js +1 -1
  3. package/dist/esm/transport/http-dispatcher.js +25 -0
  4. package/dist/esm/utils/index.js +1 -1
  5. package/dist/esm/utils/multipart-upload.js +171 -57
  6. package/dist/esm/utils/url-helpers.js +151 -23
  7. package/dist/types/index.d.ts +2 -1
  8. package/dist/types/transport/http-dispatcher.d.ts +26 -1
  9. package/dist/types/utils/index.d.ts +2 -1
  10. package/dist/types/utils/url-helpers.d.ts +88 -0
  11. package/package.json +6 -12
  12. package/dist/cjs/authentication.js +0 -317
  13. package/dist/cjs/clients/activity-client.js +0 -63
  14. package/dist/cjs/clients/app-client.js +0 -345
  15. package/dist/cjs/clients/backup-client.js +0 -47
  16. package/dist/cjs/clients/base-client.js +0 -31
  17. package/dist/cjs/clients/billing-client.js +0 -152
  18. package/dist/cjs/clients/comment-client.js +0 -91
  19. package/dist/cjs/clients/email-client.js +0 -43
  20. package/dist/cjs/clients/folder-client.js +0 -79
  21. package/dist/cjs/clients/id-mapping-client.js +0 -39
  22. package/dist/cjs/clients/insights-client.js +0 -87
  23. package/dist/cjs/clients/label-client.js +0 -126
  24. package/dist/cjs/clients/productivity-client.js +0 -27
  25. package/dist/cjs/clients/project-client.js +0 -235
  26. package/dist/cjs/clients/reminder-client.js +0 -198
  27. package/dist/cjs/clients/section-client.js +0 -117
  28. package/dist/cjs/clients/task-client.js +0 -254
  29. package/dist/cjs/clients/template-client.js +0 -88
  30. package/dist/cjs/clients/ui-extension-client.js +0 -107
  31. package/dist/cjs/clients/upload-client.js +0 -155
  32. package/dist/cjs/clients/view-options-client.js +0 -25
  33. package/dist/cjs/clients/workspace-client.js +0 -366
  34. package/dist/cjs/consts/endpoints.js +0 -224
  35. package/dist/cjs/index.js +0 -23
  36. package/dist/cjs/package.json +0 -1
  37. package/dist/cjs/test-utils/asserts.js +0 -11
  38. package/dist/cjs/test-utils/msw-setup.js +0 -97
  39. package/dist/cjs/test-utils/obsidian-fetch-adapter.js +0 -54
  40. package/dist/cjs/test-utils/test-defaults.js +0 -371
  41. package/dist/cjs/test-utils/transport-seam.js +0 -17
  42. package/dist/cjs/test-utils/webhook-fixtures.js +0 -32
  43. package/dist/cjs/todoist-api.js +0 -1711
  44. package/dist/cjs/transport/fetch-with-retry.js +0 -219
  45. package/dist/cjs/transport/http-client.js +0 -134
  46. package/dist/cjs/transport/http-dispatcher.js +0 -173
  47. package/dist/cjs/transport/sync-request.js +0 -83
  48. package/dist/cjs/types/activity/index.js +0 -18
  49. package/dist/cjs/types/activity/requests.js +0 -2
  50. package/dist/cjs/types/activity/types.js +0 -28
  51. package/dist/cjs/types/apps/index.js +0 -18
  52. package/dist/cjs/types/apps/requests.js +0 -2
  53. package/dist/cjs/types/apps/types.js +0 -254
  54. package/dist/cjs/types/backups/index.js +0 -18
  55. package/dist/cjs/types/backups/requests.js +0 -2
  56. package/dist/cjs/types/backups/types.js +0 -8
  57. package/dist/cjs/types/billing/index.js +0 -18
  58. package/dist/cjs/types/billing/requests.js +0 -2
  59. package/dist/cjs/types/billing/types.js +0 -92
  60. package/dist/cjs/types/comments/index.js +0 -18
  61. package/dist/cjs/types/comments/requests.js +0 -2
  62. package/dist/cjs/types/comments/types.js +0 -60
  63. package/dist/cjs/types/common.js +0 -10
  64. package/dist/cjs/types/emails/index.js +0 -17
  65. package/dist/cjs/types/emails/requests.js +0 -5
  66. package/dist/cjs/types/errors.js +0 -29
  67. package/dist/cjs/types/folders/index.js +0 -17
  68. package/dist/cjs/types/folders/requests.js +0 -2
  69. package/dist/cjs/types/http.js +0 -24
  70. package/dist/cjs/types/id-mappings/index.js +0 -18
  71. package/dist/cjs/types/id-mappings/requests.js +0 -20
  72. package/dist/cjs/types/id-mappings/types.js +0 -12
  73. package/dist/cjs/types/index.js +0 -40
  74. package/dist/cjs/types/insights/index.js +0 -18
  75. package/dist/cjs/types/insights/requests.js +0 -2
  76. package/dist/cjs/types/insights/types.js +0 -80
  77. package/dist/cjs/types/labels/index.js +0 -18
  78. package/dist/cjs/types/labels/requests.js +0 -2
  79. package/dist/cjs/types/labels/types.js +0 -11
  80. package/dist/cjs/types/productivity/index.js +0 -17
  81. package/dist/cjs/types/productivity/types.js +0 -68
  82. package/dist/cjs/types/projects/index.js +0 -18
  83. package/dist/cjs/types/projects/requests.js +0 -2
  84. package/dist/cjs/types/projects/types.js +0 -66
  85. package/dist/cjs/types/reminders/index.js +0 -17
  86. package/dist/cjs/types/reminders/requests.js +0 -95
  87. package/dist/cjs/types/sections/index.js +0 -18
  88. package/dist/cjs/types/sections/requests.js +0 -2
  89. package/dist/cjs/types/sections/types.js +0 -25
  90. package/dist/cjs/types/sync/commands/calendars.js +0 -2
  91. package/dist/cjs/types/sync/commands/filters.js +0 -2
  92. package/dist/cjs/types/sync/commands/folders.js +0 -2
  93. package/dist/cjs/types/sync/commands/index.js +0 -34
  94. package/dist/cjs/types/sync/commands/labels.js +0 -5
  95. package/dist/cjs/types/sync/commands/notes.js +0 -2
  96. package/dist/cjs/types/sync/commands/notifications.js +0 -2
  97. package/dist/cjs/types/sync/commands/others.js +0 -2
  98. package/dist/cjs/types/sync/commands/project-view-options.js +0 -2
  99. package/dist/cjs/types/sync/commands/projects.js +0 -2
  100. package/dist/cjs/types/sync/commands/reminders.js +0 -2
  101. package/dist/cjs/types/sync/commands/sections.js +0 -2
  102. package/dist/cjs/types/sync/commands/shared.js +0 -20
  103. package/dist/cjs/types/sync/commands/sharing.js +0 -2
  104. package/dist/cjs/types/sync/commands/tasks.js +0 -2
  105. package/dist/cjs/types/sync/commands/view-options.js +0 -2
  106. package/dist/cjs/types/sync/commands/workspace-filters.js +0 -2
  107. package/dist/cjs/types/sync/commands/workspaces.js +0 -2
  108. package/dist/cjs/types/sync/index.js +0 -22
  109. package/dist/cjs/types/sync/request.js +0 -2
  110. package/dist/cjs/types/sync/resource-types.js +0 -39
  111. package/dist/cjs/types/sync/resources/calendars.js +0 -27
  112. package/dist/cjs/types/sync/resources/collaborators.js +0 -21
  113. package/dist/cjs/types/sync/resources/completed-info.js +0 -24
  114. package/dist/cjs/types/sync/resources/filters.js +0 -14
  115. package/dist/cjs/types/sync/resources/folders.js +0 -12
  116. package/dist/cjs/types/sync/resources/index.js +0 -32
  117. package/dist/cjs/types/sync/resources/live-notifications.js +0 -38
  118. package/dist/cjs/types/sync/resources/notes.js +0 -21
  119. package/dist/cjs/types/sync/resources/reminders.js +0 -50
  120. package/dist/cjs/types/sync/resources/suggestions.js +0 -36
  121. package/dist/cjs/types/sync/resources/tooltips.js +0 -8
  122. package/dist/cjs/types/sync/resources/user-plan-limits.js +0 -20
  123. package/dist/cjs/types/sync/resources/user-settings.js +0 -40
  124. package/dist/cjs/types/sync/resources/user.js +0 -110
  125. package/dist/cjs/types/sync/resources/view-options.js +0 -86
  126. package/dist/cjs/types/sync/resources/workspace-filters.js +0 -19
  127. package/dist/cjs/types/sync/resources/workspaces.js +0 -72
  128. package/dist/cjs/types/sync/response.js +0 -54
  129. package/dist/cjs/types/sync/user-preferences.js +0 -71
  130. package/dist/cjs/types/tasks/index.js +0 -18
  131. package/dist/cjs/types/tasks/requests.js +0 -2
  132. package/dist/cjs/types/tasks/types.js +0 -59
  133. package/dist/cjs/types/templates/index.js +0 -17
  134. package/dist/cjs/types/templates/requests.js +0 -2
  135. package/dist/cjs/types/ui-extensions/index.js +0 -18
  136. package/dist/cjs/types/ui-extensions/requests.js +0 -2
  137. package/dist/cjs/types/ui-extensions/types.js +0 -77
  138. package/dist/cjs/types/uploads/index.js +0 -17
  139. package/dist/cjs/types/uploads/requests.js +0 -2
  140. package/dist/cjs/types/users/index.js +0 -17
  141. package/dist/cjs/types/users/types.js +0 -51
  142. package/dist/cjs/types/webhooks/comments.js +0 -96
  143. package/dist/cjs/types/webhooks/envelope.js +0 -26
  144. package/dist/cjs/types/webhooks/filters.js +0 -30
  145. package/dist/cjs/types/webhooks/index.js +0 -25
  146. package/dist/cjs/types/webhooks/labels.js +0 -54
  147. package/dist/cjs/types/webhooks/projects.js +0 -36
  148. package/dist/cjs/types/webhooks/reminders.js +0 -35
  149. package/dist/cjs/types/webhooks/sections.js +0 -53
  150. package/dist/cjs/types/webhooks/tasks.js +0 -68
  151. package/dist/cjs/types/webhooks/types.js +0 -55
  152. package/dist/cjs/types/workspaces/index.js +0 -18
  153. package/dist/cjs/types/workspaces/requests.js +0 -2
  154. package/dist/cjs/types/workspaces/types.js +0 -154
  155. package/dist/cjs/utils/activity-helpers.js +0 -58
  156. package/dist/cjs/utils/case-conversion.js +0 -69
  157. package/dist/cjs/utils/colors.js +0 -143
  158. package/dist/cjs/utils/file-response.js +0 -32
  159. package/dist/cjs/utils/headers.js +0 -16
  160. package/dist/cjs/utils/index.js +0 -31
  161. package/dist/cjs/utils/multipart-upload.js +0 -179
  162. package/dist/cjs/utils/processing-helpers.js +0 -18
  163. package/dist/cjs/utils/project-helpers.js +0 -20
  164. package/dist/cjs/utils/request-helpers.js +0 -21
  165. package/dist/cjs/utils/sanitization.js +0 -116
  166. package/dist/cjs/utils/sync-helpers.js +0 -22
  167. package/dist/cjs/utils/task-sorting.js +0 -281
  168. package/dist/cjs/utils/uncompletable-helpers.js +0 -60
  169. package/dist/cjs/utils/url-helpers.js +0 -74
  170. package/dist/cjs/utils/validators.js +0 -108
  171. package/dist/cjs/utils/view-options.js +0 -19
  172. package/dist/cjs/utils/webhook-parser.js +0 -60
@@ -1,72 +0,0 @@
1
- "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.SyncWorkspaceSchema = void 0;
15
- const zod_1 = require("zod");
16
- const common_1 = require("../../common");
17
- const types_1 = require("../../workspaces/types");
18
- /**
19
- * Sync API workspace resource.
20
- *
21
- * This is a superset of the REST `WorkspaceSchema` — the Sync API returns
22
- * additional fields like description, isDeleted, isCollapsed, member counts,
23
- * domain settings, and sorting preferences.
24
- */
25
- exports.SyncWorkspaceSchema = zod_1.z
26
- .looseObject({
27
- id: common_1.StringOrNumberSchema,
28
- name: zod_1.z.string(),
29
- description: zod_1.z.string(),
30
- logoBig: zod_1.z.string().nullish(),
31
- logoMedium: zod_1.z.string().nullish(),
32
- logoSmall: zod_1.z.string().nullish(),
33
- logoS640: zod_1.z.string().nullish(),
34
- creatorId: common_1.StringOrNumberSchema,
35
- createdAt: zod_1.z.coerce.date().optional(),
36
- dateCreated: zod_1.z.coerce.date().optional(),
37
- isDeleted: zod_1.z.boolean(),
38
- isCollapsed: zod_1.z.boolean(),
39
- role: types_1.WorkspaceRoleSchema.optional(),
40
- plan: types_1.WorkspacePlanSchema,
41
- limits: types_1.WorkspaceLimitsSchema.optional(),
42
- inviteCode: zod_1.z.string().nullable().optional(),
43
- isLinkSharingEnabled: zod_1.z.boolean().nullable().optional(),
44
- isGuestAllowed: zod_1.z.boolean().nullable().optional(),
45
- currentActiveProjects: zod_1.z.number().nullable(),
46
- currentMemberCount: zod_1.z.number().nullable(),
47
- memberCountByType: zod_1.z
48
- .object({
49
- adminCount: zod_1.z.number().int(),
50
- guestCount: zod_1.z.number().int(),
51
- memberCount: zod_1.z.number().int(),
52
- })
53
- .optional(),
54
- currentTemplateCount: zod_1.z.number().nullable(),
55
- pendingInvitations: zod_1.z.array(zod_1.z.string()).nullable().optional(),
56
- domainName: zod_1.z.string().nullish(),
57
- domainDiscovery: zod_1.z.boolean().nullish(),
58
- restrictEmailDomains: zod_1.z.boolean().nullish(),
59
- adminSortingApplied: zod_1.z.boolean(),
60
- projectSortPreference: zod_1.z.string().nullish(),
61
- defaultCollaborators: zod_1.z
62
- .object({
63
- predefinedGroupIds: zod_1.z.array(zod_1.z.string()),
64
- userIds: zod_1.z.array(common_1.StringOrNumberSchema),
65
- })
66
- .optional(),
67
- properties: types_1.WorkspacePropertiesSchema.optional(),
68
- })
69
- .transform((_a) => {
70
- var { dateCreated, createdAt } = _a, rest = __rest(_a, ["dateCreated", "createdAt"]);
71
- return (Object.assign(Object.assign({}, rest), { createdAt: createdAt !== null && createdAt !== void 0 ? createdAt : dateCreated }));
72
- });
@@ -1,54 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SyncResponseSchema = exports.SyncErrorSchema = void 0;
4
- const zod_1 = require("zod");
5
- const types_1 = require("../labels/types");
6
- const types_2 = require("../projects/types");
7
- const types_3 = require("../sections/types");
8
- const types_4 = require("../tasks/types");
9
- const types_5 = require("../workspaces/types");
10
- const resources_1 = require("./resources");
11
- exports.SyncErrorSchema = zod_1.z.object({
12
- error: zod_1.z.string(),
13
- errorCode: zod_1.z.number(),
14
- errorExtra: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()),
15
- errorTag: zod_1.z.string(),
16
- httpCode: zod_1.z.number(),
17
- });
18
- exports.SyncResponseSchema = zod_1.z.looseObject({
19
- syncToken: zod_1.z.string().optional(),
20
- fullSync: zod_1.z.boolean().optional(),
21
- syncStatus: zod_1.z.record(zod_1.z.string(), zod_1.z.union([zod_1.z.literal('ok'), exports.SyncErrorSchema])).optional(),
22
- tempIdMapping: zod_1.z.record(zod_1.z.string(), zod_1.z.string()).optional(),
23
- items: zod_1.z.array(types_4.TaskSchema).optional(),
24
- projects: zod_1.z.array(types_2.ProjectSchema).optional(),
25
- sections: zod_1.z.array(types_3.SectionSchema).optional(),
26
- labels: zod_1.z.array(types_1.LabelSchema).optional(),
27
- notes: zod_1.z.array(resources_1.NoteSchema).optional(),
28
- projectNotes: zod_1.z.array(resources_1.NoteSchema).optional(),
29
- filters: zod_1.z.array(resources_1.FilterSchema).optional(),
30
- reminders: zod_1.z.array(resources_1.ReminderSchema).optional(),
31
- remindersLocation: zod_1.z.array(resources_1.LocationReminderSchema).optional(),
32
- locations: zod_1.z.array(zod_1.z.record(zod_1.z.string(), zod_1.z.unknown())).optional(),
33
- user: resources_1.SyncUserSchema.optional(),
34
- liveNotifications: zod_1.z.array(resources_1.LiveNotificationSchema).optional(),
35
- collaborators: zod_1.z.array(resources_1.CollaboratorSchema).optional(),
36
- collaboratorStates: zod_1.z.array(resources_1.CollaboratorStateSchema).optional(),
37
- userSettings: resources_1.UserSettingsSchema.optional(),
38
- notificationSettings: zod_1.z.record(zod_1.z.string(), zod_1.z.boolean()).optional(),
39
- userPlanLimits: resources_1.UserPlanLimitsSchema.optional(),
40
- completedInfo: zod_1.z.array(resources_1.CompletedInfoSchema).optional(),
41
- stats: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
42
- workspaces: zod_1.z.array(resources_1.SyncWorkspaceSchema).optional(),
43
- workspaceUsers: zod_1.z.array(types_5.WorkspaceUserSchema).optional(),
44
- workspaceFilters: zod_1.z.array(resources_1.WorkspaceFilterSchema).optional(),
45
- viewOptions: zod_1.z.array(resources_1.ViewOptionsSchema).optional(),
46
- projectViewOptionsDefaults: zod_1.z.array(resources_1.ProjectViewOptionsDefaultsSchema).optional(),
47
- roleActions: zod_1.z.array(zod_1.z.record(zod_1.z.string(), zod_1.z.unknown())).optional(),
48
- folders: zod_1.z.array(resources_1.FolderSchema).optional(),
49
- dayOrders: zod_1.z.record(zod_1.z.string(), zod_1.z.number()).optional(),
50
- calendars: zod_1.z.array(resources_1.CalendarSchema).optional(),
51
- calendarAccounts: zod_1.z.array(resources_1.CalendarAccountSchema).optional(),
52
- suggestions: zod_1.z.array(resources_1.SuggestionSchema).optional(),
53
- tooltips: resources_1.TooltipsSchema.optional(),
54
- });
@@ -1,71 +0,0 @@
1
- "use strict";
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 = 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
- const zod_1 = require("zod");
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 = {
28
- 1: 'Monday',
29
- 2: 'Tuesday',
30
- 3: 'Wednesday',
31
- 4: 'Thursday',
32
- 5: 'Friday',
33
- 6: 'Saturday',
34
- 7: 'Sunday',
35
- };
36
- exports.DATE_FORMAT_TO_API = {
37
- 'DD/MM/YYYY': 0,
38
- 'MM/DD/YYYY': 1,
39
- };
40
- exports.TIME_FORMAT_TO_API = { '24h': 0, '12h': 1 };
41
- exports.DAY_OF_WEEK_TO_API = {
42
- Monday: 1,
43
- Tuesday: 2,
44
- Wednesday: 3,
45
- Thursday: 4,
46
- Friday: 5,
47
- Saturday: 6,
48
- Sunday: 7,
49
- };
50
- /** Zod read-schema: parse API 0/1 integer, emit boolean */
51
- exports.BooleanFromZeroOneSchema = zod_1.z
52
- .union([zod_1.z.literal(0), zod_1.z.literal(1)])
53
- .transform((v) => v === 1);
54
- /** Zod read-schemas: parse API numbers, emit descriptive strings */
55
- exports.DateFormatSchema = zod_1.z
56
- .union([zod_1.z.literal(0), zod_1.z.literal(1)])
57
- .transform((v) => exports.DATE_FORMAT_FROM_API[v]);
58
- exports.TimeFormatSchema = zod_1.z
59
- .union([zod_1.z.literal(0), zod_1.z.literal(1)])
60
- .transform((v) => exports.TIME_FORMAT_FROM_API[v]);
61
- exports.DayOfWeekSchema = zod_1.z
62
- .union([
63
- zod_1.z.literal(1),
64
- zod_1.z.literal(2),
65
- zod_1.z.literal(3),
66
- zod_1.z.literal(4),
67
- zod_1.z.literal(5),
68
- zod_1.z.literal(6),
69
- zod_1.z.literal(7),
70
- ])
71
- .transform((v) => exports.DAY_OF_WEEK_FROM_API[v]);
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./types"), exports);
18
- __exportStar(require("./requests"), exports);
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,59 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TaskSchema = exports.DeadlineSchema = exports.DurationSchema = exports.DURATION_UNITS = exports.DueDateSchema = void 0;
4
- const zod_1 = require("zod");
5
- const uncompletable_helpers_1 = require("../../utils/uncompletable-helpers");
6
- const url_helpers_1 = require("../../utils/url-helpers");
7
- exports.DueDateSchema = zod_1.z
8
- .object({
9
- isRecurring: zod_1.z.boolean(),
10
- string: zod_1.z.string(),
11
- date: zod_1.z.string(),
12
- })
13
- .extend({
14
- datetime: zod_1.z.string().nullable().optional(),
15
- timezone: zod_1.z.string().nullable().optional(),
16
- lang: zod_1.z.string().nullable().optional(),
17
- });
18
- /** Available duration units for task deadlines. */
19
- exports.DURATION_UNITS = ['minute', 'day'];
20
- exports.DurationSchema = zod_1.z.object({
21
- amount: zod_1.z.number().positive('Value should be greater than zero'),
22
- unit: zod_1.z.enum(exports.DURATION_UNITS),
23
- });
24
- exports.DeadlineSchema = zod_1.z.object({
25
- date: zod_1.z.string(),
26
- lang: zod_1.z.string(),
27
- });
28
- exports.TaskSchema = zod_1.z
29
- .object({
30
- id: zod_1.z.string(),
31
- userId: zod_1.z.string(),
32
- projectId: zod_1.z.string(),
33
- sectionId: zod_1.z.string().nullable(),
34
- parentId: zod_1.z.string().nullable(),
35
- addedByUid: zod_1.z.string().nullable(),
36
- assignedByUid: zod_1.z.string().nullable(),
37
- responsibleUid: zod_1.z.string().nullable(),
38
- labels: zod_1.z.array(zod_1.z.string()),
39
- deadline: exports.DeadlineSchema.nullable(),
40
- duration: exports.DurationSchema.nullable(),
41
- checked: zod_1.z.boolean(),
42
- isDeleted: zod_1.z.boolean(),
43
- addedAt: zod_1.z.coerce.date().nullable(),
44
- completedAt: zod_1.z.coerce.date().nullable(),
45
- updatedAt: zod_1.z.coerce.date().nullable(),
46
- due: exports.DueDateSchema.nullable(),
47
- priority: zod_1.z.number().int(),
48
- childOrder: zod_1.z.number().int(),
49
- content: zod_1.z.string(),
50
- description: zod_1.z.string(),
51
- dayOrder: zod_1.z.number().int(),
52
- isCollapsed: zod_1.z.boolean(),
53
- isUncompletable: zod_1.z.boolean().default(false),
54
- })
55
- .transform((data) => {
56
- // Auto-detect uncompletable status from content prefix
57
- const isUncompletable = (0, uncompletable_helpers_1.hasUncompletablePrefix)(data.content);
58
- return Object.assign(Object.assign({}, data), { isUncompletable, url: (0, url_helpers_1.getTaskUrl)(data.id, data.content) });
59
- });
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./requests"), exports);
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./types"), exports);
18
- __exportStar(require("./requests"), exports);
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,77 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UiExtensionSchema = exports.SettingsExtensionSchema = exports.ComposerExtensionSchema = exports.ContextMenuExtensionSchema = exports.UiExtensionBaseSchema = exports.ComposerExtensionContextSchema = exports.COMPOSER_EXTENSION_CONTEXTS = exports.ContextMenuExtensionContextSchema = exports.CONTEXT_MENU_EXTENSION_CONTEXTS = exports.UI_EXTENSION_TYPES = exports.UiExtensionTypeEnum = void 0;
4
- const zod_1 = require("zod");
5
- const common_1 = require("../common");
6
- /**
7
- * Discriminator values for the UI extension variants.
8
- * Exposed as an enum-like object because the values are used in `z.literal()`
9
- * across multiple variant schemas (see AGENTS.md "Discriminated unions" exception).
10
- */
11
- exports.UiExtensionTypeEnum = {
12
- ContextMenu: 'context-menu',
13
- Composer: 'composer',
14
- Settings: 'settings',
15
- };
16
- /**
17
- * All UI extension type values.
18
- */
19
- exports.UI_EXTENSION_TYPES = [
20
- exports.UiExtensionTypeEnum.ContextMenu,
21
- exports.UiExtensionTypeEnum.Composer,
22
- exports.UiExtensionTypeEnum.Settings,
23
- ];
24
- /**
25
- * Context locations where a context-menu extension can appear.
26
- */
27
- exports.CONTEXT_MENU_EXTENSION_CONTEXTS = ['project', 'task'];
28
- exports.ContextMenuExtensionContextSchema = zod_1.z.enum(exports.CONTEXT_MENU_EXTENSION_CONTEXTS);
29
- /**
30
- * Composer locations where a composer extension can appear.
31
- */
32
- exports.COMPOSER_EXTENSION_CONTEXTS = ['task', 'comment'];
33
- exports.ComposerExtensionContextSchema = zod_1.z.enum(exports.COMPOSER_EXTENSION_CONTEXTS);
34
- /**
35
- * Shared fields across all UI extension variants.
36
- */
37
- exports.UiExtensionBaseSchema = zod_1.z.object({
38
- id: common_1.StringOrNumberSchema,
39
- integrationId: common_1.StringOrNumberSchema,
40
- extensionId: zod_1.z.string(),
41
- url: zod_1.z.string(),
42
- icon: zod_1.z.string().nullable(),
43
- name: zod_1.z.string(),
44
- description: zod_1.z.string(),
45
- width: zod_1.z.number().int().nullable(),
46
- height: zod_1.z.number().int().nullable(),
47
- defVersion: zod_1.z.number().int(),
48
- minimumCardistVersion: zod_1.z.string(),
49
- });
50
- /**
51
- * Schema for a context-menu UI extension.
52
- */
53
- exports.ContextMenuExtensionSchema = exports.UiExtensionBaseSchema.extend({
54
- extensionType: zod_1.z.literal(exports.UiExtensionTypeEnum.ContextMenu),
55
- contextType: exports.ContextMenuExtensionContextSchema,
56
- });
57
- /**
58
- * Schema for a composer UI extension.
59
- */
60
- exports.ComposerExtensionSchema = exports.UiExtensionBaseSchema.extend({
61
- extensionType: zod_1.z.literal(exports.UiExtensionTypeEnum.Composer),
62
- composerType: exports.ComposerExtensionContextSchema,
63
- });
64
- /**
65
- * Schema for a settings UI extension.
66
- */
67
- exports.SettingsExtensionSchema = exports.UiExtensionBaseSchema.extend({
68
- extensionType: zod_1.z.literal(exports.UiExtensionTypeEnum.Settings),
69
- });
70
- /**
71
- * Discriminated union of all UI extension variants.
72
- */
73
- exports.UiExtensionSchema = zod_1.z.discriminatedUnion('extensionType', [
74
- exports.ContextMenuExtensionSchema,
75
- exports.ComposerExtensionSchema,
76
- exports.SettingsExtensionSchema,
77
- ]);
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./requests"), exports);
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./types"), exports);
@@ -1,51 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CurrentUserSchema = exports.PREMIUM_STATUSES = exports.TimezoneInfoSchema = exports.UserSchema = void 0;
4
- const zod_1 = require("zod");
5
- exports.UserSchema = zod_1.z.object({
6
- id: zod_1.z.string(),
7
- name: zod_1.z.string(),
8
- email: zod_1.z.string(),
9
- });
10
- exports.TimezoneInfoSchema = zod_1.z.object({
11
- gmtString: zod_1.z.string(),
12
- hours: zod_1.z.number().int(),
13
- isDst: zod_1.z.number().int(),
14
- minutes: zod_1.z.number().int(),
15
- timezone: zod_1.z.string(),
16
- });
17
- /** Available user premium statuses. */
18
- exports.PREMIUM_STATUSES = [
19
- 'not_premium',
20
- 'current_personal_plan',
21
- 'legacy_personal_plan',
22
- 'teams_business_member',
23
- ];
24
- exports.CurrentUserSchema = zod_1.z.object({
25
- id: zod_1.z.string(),
26
- email: zod_1.z.string(),
27
- fullName: zod_1.z.string(),
28
- avatarBig: zod_1.z.string().nullish(),
29
- avatarMedium: zod_1.z.string().nullish(),
30
- avatarS640: zod_1.z.string().nullish(),
31
- avatarSmall: zod_1.z.string().nullish(),
32
- businessAccountId: zod_1.z.string().nullable(),
33
- isPremium: zod_1.z.boolean(),
34
- premiumStatus: zod_1.z.enum(exports.PREMIUM_STATUSES),
35
- dateFormat: zod_1.z.number().int(),
36
- timeFormat: zod_1.z.number().int(),
37
- weeklyGoal: zod_1.z.number().int(),
38
- dailyGoal: zod_1.z.number().int(),
39
- completedCount: zod_1.z.number().int(),
40
- completedToday: zod_1.z.number().int(),
41
- karma: zod_1.z.number(),
42
- karmaTrend: zod_1.z.string(),
43
- lang: zod_1.z.string(),
44
- nextWeek: zod_1.z.number().int(),
45
- startDay: zod_1.z.number().int(),
46
- startPage: zod_1.z.string(),
47
- tzInfo: exports.TimezoneInfoSchema,
48
- inboxProjectId: zod_1.z.string(),
49
- daysOff: zod_1.z.array(zod_1.z.number().int()),
50
- weekendStartDay: zod_1.z.number().int(),
51
- });
@@ -1,96 +0,0 @@
1
- "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.CommentDeletedPayloadSchema = exports.CommentUpdatedPayloadSchema = exports.CommentAddedPayloadSchema = exports.WebhookCommentSchema = exports.WebhookProjectCommentSchema = exports.WebhookItemCommentSchema = exports.COMMENT_WEBHOOK_EVENTS = exports.CommentWebhookEventEnum = void 0;
15
- const zod_1 = require("zod");
16
- const types_1 = require("../comments/types");
17
- const types_2 = require("../tasks/types");
18
- const envelope_1 = require("./envelope");
19
- /**
20
- * Enum-like object of comment (`note:*`) webhook event names. Single source
21
- * of truth for the discriminator values — `COMMENT_WEBHOOK_EVENTS` and every
22
- * `z.literal()` below derive from it.
23
- *
24
- * The on-the-wire event names remain `note:*` for historical reasons; the
25
- * SDK types use `Comment*` to match the rest of the public API where the
26
- * resource is named `Comment`.
27
- */
28
- exports.CommentWebhookEventEnum = {
29
- Added: 'note:added',
30
- Updated: 'note:updated',
31
- Deleted: 'note:deleted',
32
- };
33
- /**
34
- * Webhook events that carry a comment as their `eventData`.
35
- */
36
- exports.COMMENT_WEBHOOK_EVENTS = [
37
- exports.CommentWebhookEventEnum.Added,
38
- exports.CommentWebhookEventEnum.Updated,
39
- exports.CommentWebhookEventEnum.Deleted,
40
- ];
41
- /**
42
- * Fields common to both item and project comment payloads.
43
- *
44
- * `postedAt` and `postedUid` are nullable here (unlike
45
- * {@link RawCommentSchema}) because webhook payloads may omit them — for
46
- * example when the poster could not be resolved, or on a deleted-note
47
- * tombstone.
48
- */
49
- const WebhookCommentBaseSchema = zod_1.z.object({
50
- id: zod_1.z.string(),
51
- content: zod_1.z.string(),
52
- postedAt: zod_1.z.coerce.date().nullable(),
53
- postedUid: zod_1.z.string().nullable(),
54
- fileAttachment: types_1.AttachmentSchema.nullable(),
55
- uidsToNotify: zod_1.z.array(zod_1.z.string()).nullable(),
56
- reactions: zod_1.z.record(zod_1.z.string(), zod_1.z.array(zod_1.z.string())).nullable(),
57
- isDeleted: zod_1.z.boolean(),
58
- });
59
- /**
60
- * A comment attached to a task, delivered in a webhook payload.
61
- *
62
- * Webhook item-comment payloads carry two fields that don't appear on the
63
- * REST comment resource: `url` (the direct task URL) and `item` (the full
64
- * embedded {@link Task}). Both are parsed here so consumers handling a
65
- * `note:added` event also get the task it belongs to.
66
- *
67
- * `itemId` is exposed as `taskId` to match the rest of the SDK surface.
68
- */
69
- exports.WebhookItemCommentSchema = WebhookCommentBaseSchema.extend({
70
- itemId: zod_1.z.string(),
71
- url: zod_1.z.string(),
72
- item: types_2.TaskSchema,
73
- })
74
- .strict()
75
- .transform((_a) => {
76
- var { itemId } = _a, rest = __rest(_a, ["itemId"]);
77
- return (Object.assign(Object.assign({}, rest), { taskId: itemId }));
78
- });
79
- /**
80
- * A comment attached to a project, delivered in a webhook payload.
81
- *
82
- * Project comments do not carry the extra `url` or embedded project fields
83
- * that item comments carry for the parent task.
84
- */
85
- exports.WebhookProjectCommentSchema = WebhookCommentBaseSchema.extend({
86
- projectId: zod_1.z.string(),
87
- }).strict();
88
- /**
89
- * The `eventData` of a `note:*` webhook payload — either an item comment
90
- * (includes `taskId` and an embedded {@link Task}) or a project comment
91
- * (includes `projectId`). Narrow with `'taskId' in eventData`.
92
- */
93
- exports.WebhookCommentSchema = zod_1.z.union([exports.WebhookItemCommentSchema, exports.WebhookProjectCommentSchema]);
94
- exports.CommentAddedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.CommentWebhookEventEnum.Added), eventData: exports.WebhookCommentSchema }));
95
- exports.CommentUpdatedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.CommentWebhookEventEnum.Updated), eventData: exports.WebhookCommentSchema }));
96
- exports.CommentDeletedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.CommentWebhookEventEnum.Deleted), eventData: exports.WebhookCommentSchema }));
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseWebhookEnvelopeShape = exports.WebhookInitiatorSchema = void 0;
4
- const zod_1 = require("zod");
5
- const types_1 = require("../apps/types");
6
- /**
7
- * Collaborator info for the user that triggered a webhook event.
8
- * @see https://developer.todoist.com/sync/v1/#webhooks
9
- */
10
- exports.WebhookInitiatorSchema = zod_1.z.object({
11
- id: zod_1.z.string(),
12
- fullName: zod_1.z.string(),
13
- email: zod_1.z.string(),
14
- imageId: zod_1.z.string().nullable(),
15
- isPremium: zod_1.z.boolean(),
16
- });
17
- /**
18
- * Fields common to every webhook payload, regardless of `eventName`.
19
- * Meant to be spread into per-event variant schemas.
20
- */
21
- exports.BaseWebhookEnvelopeShape = {
22
- version: types_1.WebhookVersionSchema,
23
- userId: zod_1.z.string(),
24
- initiator: exports.WebhookInitiatorSchema,
25
- triggeredAt: zod_1.z.coerce.date(),
26
- };
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FilterDeletedPayloadSchema = exports.FilterUpdatedPayloadSchema = exports.FilterAddedPayloadSchema = exports.FILTER_WEBHOOK_EVENTS = exports.FilterWebhookEventEnum = void 0;
4
- const zod_1 = require("zod");
5
- const filters_1 = require("../sync/resources/filters");
6
- const envelope_1 = require("./envelope");
7
- /**
8
- * Enum-like object of filter (`filter:*`) webhook event names. Single
9
- * source of truth for the discriminator values — `FILTER_WEBHOOK_EVENTS`
10
- * and every `z.literal()` below derive from it.
11
- */
12
- exports.FilterWebhookEventEnum = {
13
- Added: 'filter:added',
14
- Updated: 'filter:updated',
15
- Deleted: 'filter:deleted',
16
- };
17
- /** Webhook events that carry a filter as their `eventData`. */
18
- exports.FILTER_WEBHOOK_EVENTS = [
19
- exports.FilterWebhookEventEnum.Added,
20
- exports.FilterWebhookEventEnum.Updated,
21
- exports.FilterWebhookEventEnum.Deleted,
22
- ];
23
- /**
24
- * Webhook filter payloads match the shared {@link Filter} resource shape,
25
- * so `eventData` reuses `FilterSchema` directly — no webhook-specific
26
- * schema is needed.
27
- */
28
- exports.FilterAddedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.FilterWebhookEventEnum.Added), eventData: filters_1.FilterSchema }));
29
- exports.FilterUpdatedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.FilterWebhookEventEnum.Updated), eventData: filters_1.FilterSchema }));
30
- exports.FilterDeletedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.FilterWebhookEventEnum.Deleted), eventData: filters_1.FilterSchema }));