@todoist/sdk 0.0.1 → 18.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 (335) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +293 -29
  3. package/dist/esm/authentication.js +307 -0
  4. package/dist/esm/clients/activity-client.js +60 -0
  5. package/dist/esm/clients/app-client.js +366 -0
  6. package/dist/esm/clients/backup-client.js +47 -0
  7. package/dist/esm/clients/base-client.js +29 -0
  8. package/dist/esm/clients/billing-client.js +160 -0
  9. package/dist/esm/clients/comment-client.js +92 -0
  10. package/dist/esm/clients/email-client.js +41 -0
  11. package/dist/esm/clients/filter-client.js +26 -0
  12. package/dist/esm/clients/folder-client.js +80 -0
  13. package/dist/esm/clients/id-mapping-client.js +37 -0
  14. package/dist/esm/clients/insights-client.js +89 -0
  15. package/dist/esm/clients/label-client.js +131 -0
  16. package/dist/esm/clients/productivity-client.js +24 -0
  17. package/dist/esm/clients/project-client.js +284 -0
  18. package/dist/esm/clients/reminder-client.js +204 -0
  19. package/dist/esm/clients/section-client.js +121 -0
  20. package/dist/esm/clients/task-client.js +264 -0
  21. package/dist/esm/clients/template-client.js +89 -0
  22. package/dist/esm/clients/ui-extension-client.js +110 -0
  23. package/dist/esm/clients/upload-client.js +153 -0
  24. package/dist/esm/clients/view-options-client.js +21 -0
  25. package/dist/esm/clients/workspace-client.js +384 -0
  26. package/dist/esm/consts/endpoints.js +193 -0
  27. package/dist/esm/index.js +5 -0
  28. package/dist/esm/test-utils/asserts.js +8 -0
  29. package/dist/esm/test-utils/msw-setup.js +88 -0
  30. package/dist/esm/test-utils/obsidian-fetch-adapter.js +51 -0
  31. package/dist/esm/test-utils/test-defaults.js +367 -0
  32. package/dist/esm/test-utils/transport-seam.js +15 -0
  33. package/dist/esm/test-utils/webhook-fixtures.js +26 -0
  34. package/dist/esm/todoist-api.js +1757 -0
  35. package/dist/esm/transport/fetch-with-retry.js +216 -0
  36. package/dist/esm/transport/http-client.js +140 -0
  37. package/dist/esm/transport/http-dispatcher.js +158 -0
  38. package/dist/esm/transport/sync-request.js +106 -0
  39. package/dist/esm/types/activity/index.js +2 -0
  40. package/dist/esm/types/activity/requests.js +1 -0
  41. package/dist/esm/types/activity/types.js +45 -0
  42. package/dist/esm/types/apps/index.js +2 -0
  43. package/dist/esm/types/apps/requests.js +1 -0
  44. package/dist/esm/types/apps/types.js +249 -0
  45. package/dist/esm/types/backups/index.js +2 -0
  46. package/dist/esm/types/backups/requests.js +1 -0
  47. package/dist/esm/types/backups/types.js +5 -0
  48. package/dist/esm/types/billing/index.js +2 -0
  49. package/dist/esm/types/billing/requests.js +1 -0
  50. package/dist/esm/types/billing/types.js +89 -0
  51. package/dist/esm/types/comments/index.js +2 -0
  52. package/dist/esm/types/comments/requests.js +1 -0
  53. package/dist/esm/types/comments/types.js +57 -0
  54. package/dist/esm/types/common.js +7 -0
  55. package/dist/esm/types/emails/index.js +1 -0
  56. package/dist/esm/types/emails/requests.js +2 -0
  57. package/dist/esm/types/errors.js +41 -0
  58. package/dist/esm/types/folders/index.js +1 -0
  59. package/dist/esm/types/folders/requests.js +1 -0
  60. package/dist/esm/types/http.js +20 -0
  61. package/dist/esm/types/id-mappings/index.js +2 -0
  62. package/dist/esm/types/id-mappings/requests.js +17 -0
  63. package/dist/esm/types/id-mappings/types.js +9 -0
  64. package/dist/esm/types/index.js +24 -0
  65. package/dist/esm/types/insights/index.js +2 -0
  66. package/dist/esm/types/insights/requests.js +1 -0
  67. package/dist/esm/types/insights/types.js +77 -0
  68. package/dist/esm/types/labels/index.js +2 -0
  69. package/dist/esm/types/labels/requests.js +1 -0
  70. package/dist/esm/types/labels/types.js +8 -0
  71. package/dist/esm/types/productivity/index.js +1 -0
  72. package/dist/esm/types/productivity/types.js +65 -0
  73. package/dist/esm/types/projects/index.js +2 -0
  74. package/dist/esm/types/projects/requests.js +1 -0
  75. package/dist/esm/types/projects/types.js +65 -0
  76. package/dist/esm/types/reminders/index.js +1 -0
  77. package/dist/esm/types/reminders/requests.js +92 -0
  78. package/dist/esm/types/sections/index.js +2 -0
  79. package/dist/esm/types/sections/requests.js +1 -0
  80. package/dist/esm/types/sections/types.js +23 -0
  81. package/dist/esm/types/sync/commands/calendars.js +1 -0
  82. package/dist/esm/types/sync/commands/filters.js +1 -0
  83. package/dist/esm/types/sync/commands/folders.js +1 -0
  84. package/dist/esm/types/sync/commands/index.js +18 -0
  85. package/dist/esm/types/sync/commands/labels.js +2 -0
  86. package/dist/esm/types/sync/commands/notes.js +1 -0
  87. package/dist/esm/types/sync/commands/notifications.js +1 -0
  88. package/dist/esm/types/sync/commands/others.js +1 -0
  89. package/dist/esm/types/sync/commands/project-view-options.js +1 -0
  90. package/dist/esm/types/sync/commands/projects.js +1 -0
  91. package/dist/esm/types/sync/commands/reminders.js +1 -0
  92. package/dist/esm/types/sync/commands/sections.js +1 -0
  93. package/dist/esm/types/sync/commands/shared.js +16 -0
  94. package/dist/esm/types/sync/commands/sharing.js +1 -0
  95. package/dist/esm/types/sync/commands/tasks.js +1 -0
  96. package/dist/esm/types/sync/commands/view-options.js +1 -0
  97. package/dist/esm/types/sync/commands/workspace-filters.js +1 -0
  98. package/dist/esm/types/sync/commands/workspaces.js +1 -0
  99. package/dist/esm/types/sync/index.js +6 -0
  100. package/dist/esm/types/sync/request.js +1 -0
  101. package/dist/esm/types/sync/resource-types.js +36 -0
  102. package/dist/esm/types/sync/resources/calendars.js +24 -0
  103. package/dist/esm/types/sync/resources/collaborators.js +21 -0
  104. package/dist/esm/types/sync/resources/completed-info.js +21 -0
  105. package/dist/esm/types/sync/resources/filters.js +12 -0
  106. package/dist/esm/types/sync/resources/folders.js +10 -0
  107. package/dist/esm/types/sync/resources/index.js +18 -0
  108. package/dist/esm/types/sync/resources/labels.js +7 -0
  109. package/dist/esm/types/sync/resources/live-notifications.js +35 -0
  110. package/dist/esm/types/sync/resources/notes.js +18 -0
  111. package/dist/esm/types/sync/resources/reminders.js +58 -0
  112. package/dist/esm/types/sync/resources/suggestions.js +33 -0
  113. package/dist/esm/types/sync/resources/tooltips.js +5 -0
  114. package/dist/esm/types/sync/resources/user-plan-limits.js +21 -0
  115. package/dist/esm/types/sync/resources/user-settings.js +41 -0
  116. package/dist/esm/types/sync/resources/user-status.js +22 -0
  117. package/dist/esm/types/sync/resources/user.js +109 -0
  118. package/dist/esm/types/sync/resources/view-options.js +128 -0
  119. package/dist/esm/types/sync/resources/workspace-filters.js +17 -0
  120. package/dist/esm/types/sync/resources/workspaces.js +69 -0
  121. package/dist/esm/types/sync/response.js +57 -0
  122. package/dist/esm/types/sync/user-preferences.js +68 -0
  123. package/dist/esm/types/tasks/index.js +2 -0
  124. package/dist/esm/types/tasks/requests.js +1 -0
  125. package/dist/esm/types/tasks/types.js +56 -0
  126. package/dist/esm/types/templates/index.js +1 -0
  127. package/dist/esm/types/templates/requests.js +1 -0
  128. package/dist/esm/types/ui-extensions/index.js +2 -0
  129. package/dist/esm/types/ui-extensions/requests.js +1 -0
  130. package/dist/esm/types/ui-extensions/types.js +74 -0
  131. package/dist/esm/types/uploads/index.js +1 -0
  132. package/dist/esm/types/uploads/requests.js +1 -0
  133. package/dist/esm/types/users/index.js +1 -0
  134. package/dist/esm/types/users/types.js +49 -0
  135. package/dist/esm/types/webhooks/comments.js +93 -0
  136. package/dist/esm/types/webhooks/envelope.js +23 -0
  137. package/dist/esm/types/webhooks/filters.js +27 -0
  138. package/dist/esm/types/webhooks/index.js +9 -0
  139. package/dist/esm/types/webhooks/labels.js +51 -0
  140. package/dist/esm/types/webhooks/projects.js +33 -0
  141. package/dist/esm/types/webhooks/reminders.js +32 -0
  142. package/dist/esm/types/webhooks/sections.js +50 -0
  143. package/dist/esm/types/webhooks/tasks.js +65 -0
  144. package/dist/esm/types/webhooks/types.js +52 -0
  145. package/dist/esm/types/workspaces/index.js +2 -0
  146. package/dist/esm/types/workspaces/requests.js +1 -0
  147. package/dist/esm/types/workspaces/types.js +151 -0
  148. package/dist/esm/utils/activity-helpers.js +53 -0
  149. package/dist/esm/utils/case-conversion.js +84 -0
  150. package/dist/esm/utils/colors.js +145 -0
  151. package/dist/esm/utils/file-response.js +29 -0
  152. package/dist/esm/utils/filter-queries.js +231 -0
  153. package/dist/esm/utils/filter-query-definitions.js +2789 -0
  154. package/dist/esm/utils/headers.js +42 -0
  155. package/dist/esm/utils/index.js +11 -0
  156. package/dist/esm/utils/multipart-upload.js +267 -0
  157. package/dist/esm/utils/person-names.js +61 -0
  158. package/dist/esm/utils/processing-helpers.js +12 -0
  159. package/dist/esm/utils/project-helpers.js +29 -0
  160. package/dist/esm/utils/request-helpers.js +43 -0
  161. package/dist/esm/utils/sanitization.js +131 -0
  162. package/dist/esm/utils/sync-helpers.js +19 -0
  163. package/dist/esm/utils/task-sorting.js +280 -0
  164. package/dist/esm/utils/uncompletable-helpers.js +54 -0
  165. package/dist/esm/utils/url-helpers.js +196 -0
  166. package/dist/esm/utils/validators.js +102 -0
  167. package/dist/esm/utils/view-options.js +15 -0
  168. package/dist/esm/utils/webhook-parser.js +56 -0
  169. package/dist/types/authentication.d.ts +262 -0
  170. package/dist/types/clients/activity-client.d.ts +12 -0
  171. package/dist/types/clients/app-client.d.ts +37 -0
  172. package/dist/types/clients/backup-client.d.ts +14 -0
  173. package/dist/types/clients/base-client.d.ts +23 -0
  174. package/dist/types/clients/billing-client.d.ts +22 -0
  175. package/dist/types/clients/comment-client.d.ts +15 -0
  176. package/dist/types/clients/email-client.d.ts +13 -0
  177. package/dist/types/clients/filter-client.d.ts +10 -0
  178. package/dist/types/clients/folder-client.d.ts +16 -0
  179. package/dist/types/clients/id-mapping-client.d.ts +13 -0
  180. package/dist/types/clients/insights-client.d.ts +18 -0
  181. package/dist/types/clients/label-client.d.ts +19 -0
  182. package/dist/types/clients/productivity-client.d.ts +12 -0
  183. package/dist/types/clients/project-client.d.ts +22 -0
  184. package/dist/types/clients/reminder-client.d.ts +25 -0
  185. package/dist/types/clients/section-client.d.ts +18 -0
  186. package/dist/types/clients/task-client.d.ts +25 -0
  187. package/dist/types/clients/template-client.d.ts +17 -0
  188. package/dist/types/clients/ui-extension-client.d.ts +18 -0
  189. package/dist/types/clients/upload-client.d.ts +17 -0
  190. package/dist/types/clients/view-options-client.d.ts +8 -0
  191. package/dist/types/clients/workspace-client.d.ts +43 -0
  192. package/dist/types/consts/endpoints.d.ts +120 -0
  193. package/dist/types/index.d.ts +6 -0
  194. package/dist/types/test-utils/asserts.d.ts +1 -0
  195. package/dist/types/test-utils/msw-setup.d.ts +33 -0
  196. package/dist/types/test-utils/obsidian-fetch-adapter.d.ts +29 -0
  197. package/dist/types/test-utils/test-defaults.d.ts +286 -0
  198. package/dist/types/test-utils/transport-seam.d.ts +1 -0
  199. package/dist/types/test-utils/webhook-fixtures.d.ts +13 -0
  200. package/dist/types/todoist-api.d.ts +1437 -0
  201. package/dist/types/transport/fetch-with-retry.d.ts +12 -0
  202. package/dist/types/transport/http-client.d.ts +25 -0
  203. package/dist/types/transport/http-dispatcher.d.ts +65 -0
  204. package/dist/types/transport/sync-request.d.ts +31 -0
  205. package/dist/types/types/activity/index.d.ts +2 -0
  206. package/dist/types/types/activity/requests.d.ts +85 -0
  207. package/dist/types/types/activity/types.d.ts +56 -0
  208. package/dist/types/types/apps/index.d.ts +2 -0
  209. package/dist/types/types/apps/requests.d.ts +89 -0
  210. package/dist/types/types/apps/types.d.ts +418 -0
  211. package/dist/types/types/backups/index.d.ts +2 -0
  212. package/dist/types/types/backups/requests.d.ts +16 -0
  213. package/dist/types/types/backups/types.d.ts +7 -0
  214. package/dist/types/types/billing/index.d.ts +2 -0
  215. package/dist/types/types/billing/requests.d.ts +62 -0
  216. package/dist/types/types/billing/types.d.ts +207 -0
  217. package/dist/types/types/comments/index.d.ts +2 -0
  218. package/dist/types/types/comments/requests.d.ts +64 -0
  219. package/dist/types/types/comments/types.d.ts +141 -0
  220. package/dist/types/types/common.d.ts +13 -0
  221. package/dist/types/types/emails/index.d.ts +1 -0
  222. package/dist/types/types/emails/requests.d.ts +30 -0
  223. package/dist/types/types/errors.d.ts +29 -0
  224. package/dist/types/types/folders/index.d.ts +1 -0
  225. package/dist/types/types/folders/requests.d.ts +20 -0
  226. package/dist/types/types/http.d.ts +104 -0
  227. package/dist/types/types/id-mappings/index.d.ts +2 -0
  228. package/dist/types/types/id-mappings/requests.d.ts +28 -0
  229. package/dist/types/types/id-mappings/types.d.ts +13 -0
  230. package/dist/types/types/index.d.ts +24 -0
  231. package/dist/types/types/insights/index.d.ts +2 -0
  232. package/dist/types/types/insights/requests.d.ts +26 -0
  233. package/dist/types/types/insights/types.d.ts +167 -0
  234. package/dist/types/types/labels/index.d.ts +2 -0
  235. package/dist/types/types/labels/requests.d.ts +75 -0
  236. package/dist/types/types/labels/types.d.ts +13 -0
  237. package/dist/types/types/productivity/index.d.ts +1 -0
  238. package/dist/types/types/productivity/types.d.ts +115 -0
  239. package/dist/types/types/projects/index.d.ts +2 -0
  240. package/dist/types/types/projects/requests.d.ts +206 -0
  241. package/dist/types/types/projects/types.d.ts +286 -0
  242. package/dist/types/types/reminders/index.d.ts +1 -0
  243. package/dist/types/types/reminders/requests.d.ts +205 -0
  244. package/dist/types/types/sections/index.d.ts +2 -0
  245. package/dist/types/types/sections/requests.d.ts +49 -0
  246. package/dist/types/types/sections/types.d.ts +70 -0
  247. package/dist/types/types/sync/commands/calendars.d.ts +14 -0
  248. package/dist/types/types/sync/commands/filters.d.ts +24 -0
  249. package/dist/types/types/sync/commands/folders.d.ts +20 -0
  250. package/dist/types/types/sync/commands/index.d.ts +167 -0
  251. package/dist/types/types/sync/commands/labels.d.ts +32 -0
  252. package/dist/types/types/sync/commands/notes.d.ts +27 -0
  253. package/dist/types/types/sync/commands/notifications.d.ts +10 -0
  254. package/dist/types/types/sync/commands/others.d.ts +61 -0
  255. package/dist/types/types/sync/commands/project-view-options.d.ts +13 -0
  256. package/dist/types/types/sync/commands/projects.d.ts +96 -0
  257. package/dist/types/types/sync/commands/reminders.d.ts +51 -0
  258. package/dist/types/types/sync/commands/sections.d.ts +36 -0
  259. package/dist/types/types/sync/commands/shared.d.ts +51 -0
  260. package/dist/types/types/sync/commands/sharing.d.ts +16 -0
  261. package/dist/types/types/sync/commands/tasks.d.ts +78 -0
  262. package/dist/types/types/sync/commands/view-options.d.ts +18 -0
  263. package/dist/types/types/sync/commands/workspace-filters.d.ts +25 -0
  264. package/dist/types/types/sync/commands/workspaces.d.ts +82 -0
  265. package/dist/types/types/sync/index.d.ts +6 -0
  266. package/dist/types/types/sync/request.d.ts +7 -0
  267. package/dist/types/types/sync/resource-types.d.ts +5 -0
  268. package/dist/types/types/sync/resources/calendars.d.ts +38 -0
  269. package/dist/types/types/sync/resources/collaborators.d.ts +45 -0
  270. package/dist/types/types/sync/resources/completed-info.d.ts +33 -0
  271. package/dist/types/types/sync/resources/filters.d.ts +13 -0
  272. package/dist/types/types/sync/resources/folders.d.ts +11 -0
  273. package/dist/types/types/sync/resources/index.d.ts +18 -0
  274. package/dist/types/types/sync/resources/labels.d.ts +12 -0
  275. package/dist/types/types/sync/resources/live-notifications.d.ts +32 -0
  276. package/dist/types/types/sync/resources/notes.d.ts +34 -0
  277. package/dist/types/types/sync/resources/reminders.d.ts +213 -0
  278. package/dist/types/types/sync/resources/suggestions.d.ts +96 -0
  279. package/dist/types/types/sync/resources/tooltips.d.ts +6 -0
  280. package/dist/types/types/sync/resources/user-plan-limits.d.ts +47 -0
  281. package/dist/types/types/sync/resources/user-settings.d.ts +40 -0
  282. package/dist/types/types/sync/resources/user-status.d.ts +46 -0
  283. package/dist/types/types/sync/resources/user.d.ts +151 -0
  284. package/dist/types/types/sync/resources/view-options.d.ts +157 -0
  285. package/dist/types/types/sync/resources/workspace-filters.d.ts +18 -0
  286. package/dist/types/types/sync/resources/workspaces.d.ts +142 -0
  287. package/dist/types/types/sync/response.d.ts +930 -0
  288. package/dist/types/types/sync/user-preferences.d.ts +39 -0
  289. package/dist/types/types/tasks/index.d.ts +2 -0
  290. package/dist/types/types/tasks/requests.d.ts +197 -0
  291. package/dist/types/types/tasks/types.d.ts +162 -0
  292. package/dist/types/types/templates/index.d.ts +1 -0
  293. package/dist/types/types/templates/requests.d.ts +92 -0
  294. package/dist/types/types/ui-extensions/index.d.ts +2 -0
  295. package/dist/types/types/ui-extensions/requests.d.ts +108 -0
  296. package/dist/types/types/ui-extensions/types.d.ts +185 -0
  297. package/dist/types/types/uploads/index.d.ts +1 -0
  298. package/dist/types/types/uploads/requests.d.ts +32 -0
  299. package/dist/types/types/users/index.d.ts +1 -0
  300. package/dist/types/types/users/types.d.ts +67 -0
  301. package/dist/types/types/webhooks/comments.d.ts +1600 -0
  302. package/dist/types/types/webhooks/envelope.d.ts +34 -0
  303. package/dist/types/types/webhooks/filters.d.ts +99 -0
  304. package/dist/types/types/webhooks/index.d.ts +9 -0
  305. package/dist/types/types/webhooks/labels.d.ts +160 -0
  306. package/dist/types/types/webhooks/projects.d.ts +365 -0
  307. package/dist/types/types/webhooks/reminders.d.ts +82 -0
  308. package/dist/types/types/webhooks/sections.d.ts +372 -0
  309. package/dist/types/types/webhooks/tasks.d.ts +981 -0
  310. package/dist/types/types/webhooks/types.d.ts +2606 -0
  311. package/dist/types/types/workspaces/index.d.ts +2 -0
  312. package/dist/types/types/workspaces/requests.d.ts +260 -0
  313. package/dist/types/types/workspaces/types.d.ts +266 -0
  314. package/dist/types/utils/activity-helpers.d.ts +28 -0
  315. package/dist/types/utils/case-conversion.d.ts +20 -0
  316. package/dist/types/utils/colors.d.ts +201 -0
  317. package/dist/types/utils/file-response.d.ts +15 -0
  318. package/dist/types/utils/filter-queries.d.ts +42 -0
  319. package/dist/types/utils/filter-query-definitions.d.ts +27 -0
  320. package/dist/types/utils/headers.d.ts +20 -0
  321. package/dist/types/utils/index.d.ts +15 -0
  322. package/dist/types/utils/multipart-upload.d.ts +58 -0
  323. package/dist/types/utils/person-names.d.ts +52 -0
  324. package/dist/types/utils/processing-helpers.d.ts +1 -0
  325. package/dist/types/utils/project-helpers.d.ts +21 -0
  326. package/dist/types/utils/request-helpers.d.ts +33 -0
  327. package/dist/types/utils/sanitization.d.ts +52 -0
  328. package/dist/types/utils/sync-helpers.d.ts +17 -0
  329. package/dist/types/utils/task-sorting.d.ts +46 -0
  330. package/dist/types/utils/uncompletable-helpers.d.ts +30 -0
  331. package/dist/types/utils/url-helpers.d.ts +120 -0
  332. package/dist/types/utils/validators.d.ts +1917 -0
  333. package/dist/types/utils/view-options.d.ts +11 -0
  334. package/dist/types/utils/webhook-parser.d.ts +48 -0
  335. package/package.json +87 -8
@@ -0,0 +1,74 @@
1
+ import { z } from 'zod';
2
+ import { StringOrNumberSchema } from '../common.js';
3
+ /**
4
+ * Discriminator values for the UI extension variants.
5
+ * Exposed as an enum-like object because the values are used in `z.literal()`
6
+ * across multiple variant schemas (see AGENTS.md "Discriminated unions" exception).
7
+ */
8
+ export const UiExtensionTypeEnum = {
9
+ ContextMenu: 'context-menu',
10
+ Composer: 'composer',
11
+ Settings: 'settings',
12
+ };
13
+ /**
14
+ * All UI extension type values.
15
+ */
16
+ export const UI_EXTENSION_TYPES = [
17
+ UiExtensionTypeEnum.ContextMenu,
18
+ UiExtensionTypeEnum.Composer,
19
+ UiExtensionTypeEnum.Settings,
20
+ ];
21
+ /**
22
+ * Context locations where a context-menu extension can appear.
23
+ */
24
+ export const CONTEXT_MENU_EXTENSION_CONTEXTS = ['project', 'task'];
25
+ export const ContextMenuExtensionContextSchema = z.enum(CONTEXT_MENU_EXTENSION_CONTEXTS);
26
+ /**
27
+ * Composer locations where a composer extension can appear.
28
+ */
29
+ export const COMPOSER_EXTENSION_CONTEXTS = ['task', 'comment'];
30
+ export const ComposerExtensionContextSchema = z.enum(COMPOSER_EXTENSION_CONTEXTS);
31
+ /**
32
+ * Shared fields across all UI extension variants.
33
+ */
34
+ export const UiExtensionBaseSchema = z.object({
35
+ id: StringOrNumberSchema,
36
+ integrationId: StringOrNumberSchema,
37
+ extensionId: z.string(),
38
+ url: z.string(),
39
+ icon: z.string().nullable(),
40
+ name: z.string(),
41
+ description: z.string(),
42
+ width: z.number().int().nullable(),
43
+ height: z.number().int().nullable(),
44
+ defVersion: z.number().int(),
45
+ minimumCardistVersion: z.string(),
46
+ });
47
+ /**
48
+ * Schema for a context-menu UI extension.
49
+ */
50
+ export const ContextMenuExtensionSchema = UiExtensionBaseSchema.extend({
51
+ extensionType: z.literal(UiExtensionTypeEnum.ContextMenu),
52
+ contextType: ContextMenuExtensionContextSchema,
53
+ });
54
+ /**
55
+ * Schema for a composer UI extension.
56
+ */
57
+ export const ComposerExtensionSchema = UiExtensionBaseSchema.extend({
58
+ extensionType: z.literal(UiExtensionTypeEnum.Composer),
59
+ composerType: ComposerExtensionContextSchema,
60
+ });
61
+ /**
62
+ * Schema for a settings UI extension.
63
+ */
64
+ export const SettingsExtensionSchema = UiExtensionBaseSchema.extend({
65
+ extensionType: z.literal(UiExtensionTypeEnum.Settings),
66
+ });
67
+ /**
68
+ * Discriminated union of all UI extension variants.
69
+ */
70
+ export const UiExtensionSchema = z.discriminatedUnion('extensionType', [
71
+ ContextMenuExtensionSchema,
72
+ ComposerExtensionSchema,
73
+ SettingsExtensionSchema,
74
+ ]);
@@ -0,0 +1 @@
1
+ export * from './requests.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export * from './types.js';
@@ -0,0 +1,49 @@
1
+ import { z } from 'zod';
2
+ export const UserSchema = z.object({
3
+ id: z.string(),
4
+ name: z.string(),
5
+ email: z.string(),
6
+ });
7
+ export const TimezoneInfoSchema = z.object({
8
+ gmtString: z.string(),
9
+ hours: z.number().int(),
10
+ isDst: z.number().int(),
11
+ minutes: z.number().int(),
12
+ timezone: z.string(),
13
+ });
14
+ /** Available user premium statuses. */
15
+ export const PREMIUM_STATUSES = [
16
+ 'not_premium',
17
+ 'current_personal_plan',
18
+ 'legacy_personal_plan',
19
+ 'teams_business_member',
20
+ ];
21
+ export const CurrentUserSchema = z.object({
22
+ id: z.string(),
23
+ email: z.string(),
24
+ fullName: z.string(),
25
+ avatarBig: z.string().nullish(),
26
+ avatarMedium: z.string().nullish(),
27
+ avatarS640: z.string().nullish(),
28
+ avatarSmall: z.string().nullish(),
29
+ businessAccountId: z.string().nullable(),
30
+ isPremium: z.boolean(),
31
+ premiumStatus: z.enum(PREMIUM_STATUSES),
32
+ dateFormat: z.number().int(),
33
+ timeFormat: z.number().int(),
34
+ weeklyGoal: z.number().int(),
35
+ dailyGoal: z.number().int(),
36
+ completedCount: z.number().int(),
37
+ completedToday: z.number().int(),
38
+ karma: z.number(),
39
+ karmaTrend: z.string(),
40
+ lang: z.string(),
41
+ nextWeek: z.number().int(),
42
+ startDay: z.number().int(),
43
+ startPage: z.string(),
44
+ tzInfo: TimezoneInfoSchema,
45
+ inboxProjectId: z.string(),
46
+ daysOff: z.array(z.number().int()),
47
+ weekendStartDay: z.number().int(),
48
+ websocketUrl: z.string().optional(),
49
+ });
@@ -0,0 +1,93 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { z } from 'zod';
13
+ import { AttachmentSchema } from '../comments/types.js';
14
+ import { TaskSchema } from '../tasks/types.js';
15
+ import { BaseWebhookEnvelopeShape } from './envelope.js';
16
+ /**
17
+ * Enum-like object of comment (`note:*`) webhook event names. Single source
18
+ * of truth for the discriminator values — `COMMENT_WEBHOOK_EVENTS` and every
19
+ * `z.literal()` below derive from it.
20
+ *
21
+ * The on-the-wire event names remain `note:*` for historical reasons; the
22
+ * SDK types use `Comment*` to match the rest of the public API where the
23
+ * resource is named `Comment`.
24
+ */
25
+ export const CommentWebhookEventEnum = {
26
+ Added: 'note:added',
27
+ Updated: 'note:updated',
28
+ Deleted: 'note:deleted',
29
+ };
30
+ /**
31
+ * Webhook events that carry a comment as their `eventData`.
32
+ */
33
+ export const COMMENT_WEBHOOK_EVENTS = [
34
+ CommentWebhookEventEnum.Added,
35
+ CommentWebhookEventEnum.Updated,
36
+ CommentWebhookEventEnum.Deleted,
37
+ ];
38
+ /**
39
+ * Fields common to both item and project comment payloads.
40
+ *
41
+ * `postedAt` and `postedUid` are nullable here (unlike
42
+ * {@link RawCommentSchema}) because webhook payloads may omit them — for
43
+ * example when the poster could not be resolved, or on a deleted-note
44
+ * tombstone.
45
+ */
46
+ const WebhookCommentBaseSchema = z.object({
47
+ id: z.string(),
48
+ content: z.string(),
49
+ postedAt: z.coerce.date().nullable(),
50
+ postedUid: z.string().nullable(),
51
+ fileAttachment: AttachmentSchema.nullable(),
52
+ uidsToNotify: z.array(z.string()).nullable(),
53
+ reactions: z.record(z.string(), z.array(z.string())).nullable(),
54
+ isDeleted: z.boolean(),
55
+ });
56
+ /**
57
+ * A comment attached to a task, delivered in a webhook payload.
58
+ *
59
+ * Webhook item-comment payloads carry two fields that don't appear on the
60
+ * REST comment resource: `url` (the direct task URL) and `item` (the full
61
+ * embedded {@link Task}). Both are parsed here so consumers handling a
62
+ * `note:added` event also get the task it belongs to.
63
+ *
64
+ * `itemId` is exposed as `taskId` to match the rest of the SDK surface.
65
+ */
66
+ export const WebhookItemCommentSchema = WebhookCommentBaseSchema.extend({
67
+ itemId: z.string(),
68
+ url: z.string(),
69
+ item: TaskSchema,
70
+ })
71
+ .strict()
72
+ .transform((_a) => {
73
+ var { itemId } = _a, rest = __rest(_a, ["itemId"]);
74
+ return (Object.assign(Object.assign({}, rest), { taskId: itemId }));
75
+ });
76
+ /**
77
+ * A comment attached to a project, delivered in a webhook payload.
78
+ *
79
+ * Project comments do not carry the extra `url` or embedded project fields
80
+ * that item comments carry for the parent task.
81
+ */
82
+ export const WebhookProjectCommentSchema = WebhookCommentBaseSchema.extend({
83
+ projectId: z.string(),
84
+ }).strict();
85
+ /**
86
+ * The `eventData` of a `note:*` webhook payload — either an item comment
87
+ * (includes `taskId` and an embedded {@link Task}) or a project comment
88
+ * (includes `projectId`). Narrow with `'taskId' in eventData`.
89
+ */
90
+ export const WebhookCommentSchema = z.union([WebhookItemCommentSchema, WebhookProjectCommentSchema]);
91
+ export const CommentAddedPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(CommentWebhookEventEnum.Added), eventData: WebhookCommentSchema }));
92
+ export const CommentUpdatedPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(CommentWebhookEventEnum.Updated), eventData: WebhookCommentSchema }));
93
+ export const CommentDeletedPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(CommentWebhookEventEnum.Deleted), eventData: WebhookCommentSchema }));
@@ -0,0 +1,23 @@
1
+ import { z } from 'zod';
2
+ import { WebhookVersionSchema } from '../apps/types.js';
3
+ /**
4
+ * Collaborator info for the user that triggered a webhook event.
5
+ * @see https://developer.todoist.com/sync/v1/#webhooks
6
+ */
7
+ export const WebhookInitiatorSchema = z.object({
8
+ id: z.string(),
9
+ fullName: z.string(),
10
+ email: z.string(),
11
+ imageId: z.string().nullable(),
12
+ isPremium: z.boolean(),
13
+ });
14
+ /**
15
+ * Fields common to every webhook payload, regardless of `eventName`.
16
+ * Meant to be spread into per-event variant schemas.
17
+ */
18
+ export const BaseWebhookEnvelopeShape = {
19
+ version: WebhookVersionSchema,
20
+ userId: z.string(),
21
+ initiator: WebhookInitiatorSchema,
22
+ triggeredAt: z.coerce.date(),
23
+ };
@@ -0,0 +1,27 @@
1
+ import { z } from 'zod';
2
+ import { FilterSchema } from '../sync/resources/filters.js';
3
+ import { BaseWebhookEnvelopeShape } from './envelope.js';
4
+ /**
5
+ * Enum-like object of filter (`filter:*`) webhook event names. Single
6
+ * source of truth for the discriminator values — `FILTER_WEBHOOK_EVENTS`
7
+ * and every `z.literal()` below derive from it.
8
+ */
9
+ export const FilterWebhookEventEnum = {
10
+ Added: 'filter:added',
11
+ Updated: 'filter:updated',
12
+ Deleted: 'filter:deleted',
13
+ };
14
+ /** Webhook events that carry a filter as their `eventData`. */
15
+ export const FILTER_WEBHOOK_EVENTS = [
16
+ FilterWebhookEventEnum.Added,
17
+ FilterWebhookEventEnum.Updated,
18
+ FilterWebhookEventEnum.Deleted,
19
+ ];
20
+ /**
21
+ * Webhook filter payloads match the shared {@link Filter} resource shape,
22
+ * so `eventData` reuses `FilterSchema` directly — no webhook-specific
23
+ * schema is needed.
24
+ */
25
+ export const FilterAddedPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(FilterWebhookEventEnum.Added), eventData: FilterSchema }));
26
+ export const FilterUpdatedPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(FilterWebhookEventEnum.Updated), eventData: FilterSchema }));
27
+ export const FilterDeletedPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(FilterWebhookEventEnum.Deleted), eventData: FilterSchema }));
@@ -0,0 +1,9 @@
1
+ export * from './comments.js';
2
+ export * from './envelope.js';
3
+ export * from './filters.js';
4
+ export * from './labels.js';
5
+ export * from './projects.js';
6
+ export * from './reminders.js';
7
+ export * from './sections.js';
8
+ export * from './tasks.js';
9
+ export * from './types.js';
@@ -0,0 +1,51 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { z } from 'zod';
13
+ import { LabelSchema } from '../labels/types.js';
14
+ import { BaseWebhookEnvelopeShape } from './envelope.js';
15
+ /**
16
+ * Enum-like object of label (`label:*`) webhook event names. Single source
17
+ * of truth for the discriminator values — `LABEL_WEBHOOK_EVENTS` and every
18
+ * `z.literal()` below derive from it.
19
+ */
20
+ export const LabelWebhookEventEnum = {
21
+ Added: 'label:added',
22
+ Updated: 'label:updated',
23
+ Deleted: 'label:deleted',
24
+ };
25
+ /** Webhook events that carry a label as their `eventData`. */
26
+ export const LABEL_WEBHOOK_EVENTS = [
27
+ LabelWebhookEventEnum.Added,
28
+ LabelWebhookEventEnum.Updated,
29
+ LabelWebhookEventEnum.Deleted,
30
+ ];
31
+ /**
32
+ * A label as delivered in a webhook payload.
33
+ *
34
+ * Webhook label payloads differ from the REST label shape in two ways:
35
+ * they use `item_order` (not `order`) and always include `is_deleted`. This
36
+ * schema reuses {@link LabelSchema}, swapping `order` for `itemOrder` on
37
+ * the input side and renaming it back after validation, and surfaces
38
+ * `isDeleted` for downstream filtering.
39
+ */
40
+ export const WebhookLabelSchema = LabelSchema.omit({ order: true })
41
+ .extend({
42
+ itemOrder: z.number().int().nullable(),
43
+ isDeleted: z.boolean(),
44
+ })
45
+ .transform((_a) => {
46
+ var { itemOrder } = _a, rest = __rest(_a, ["itemOrder"]);
47
+ return (Object.assign(Object.assign({}, rest), { order: itemOrder }));
48
+ });
49
+ export const LabelAddedPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(LabelWebhookEventEnum.Added), eventData: WebhookLabelSchema }));
50
+ export const LabelUpdatedPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(LabelWebhookEventEnum.Updated), eventData: WebhookLabelSchema }));
51
+ export const LabelDeletedPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(LabelWebhookEventEnum.Deleted), eventData: WebhookLabelSchema }));
@@ -0,0 +1,33 @@
1
+ import { z } from 'zod';
2
+ import { ProjectSchema } from '../projects/types.js';
3
+ import { BaseWebhookEnvelopeShape } from './envelope.js';
4
+ /**
5
+ * Enum-like object of project (`project:*`) webhook event names. Single
6
+ * source of truth for the discriminator values — `PROJECT_WEBHOOK_EVENTS`
7
+ * and every `z.literal()` below derive from it.
8
+ */
9
+ export const ProjectWebhookEventEnum = {
10
+ Added: 'project:added',
11
+ Updated: 'project:updated',
12
+ Deleted: 'project:deleted',
13
+ Archived: 'project:archived',
14
+ Unarchived: 'project:unarchived',
15
+ };
16
+ /** Webhook events that carry a project as their `eventData`. */
17
+ export const PROJECT_WEBHOOK_EVENTS = [
18
+ ProjectWebhookEventEnum.Added,
19
+ ProjectWebhookEventEnum.Updated,
20
+ ProjectWebhookEventEnum.Deleted,
21
+ ProjectWebhookEventEnum.Archived,
22
+ ProjectWebhookEventEnum.Unarchived,
23
+ ];
24
+ /**
25
+ * Webhook project payloads match the shape of the shared {@link Project}
26
+ * resource — either a personal or a workspace project. No webhook-specific
27
+ * schema is needed; `ProjectSchema` already dispatches on `workspaceId`.
28
+ */
29
+ export const ProjectAddedPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(ProjectWebhookEventEnum.Added), eventData: ProjectSchema }));
30
+ export const ProjectUpdatedPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(ProjectWebhookEventEnum.Updated), eventData: ProjectSchema }));
31
+ export const ProjectDeletedPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(ProjectWebhookEventEnum.Deleted), eventData: ProjectSchema }));
32
+ export const ProjectArchivedPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(ProjectWebhookEventEnum.Archived), eventData: ProjectSchema }));
33
+ export const ProjectUnarchivedPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(ProjectWebhookEventEnum.Unarchived), eventData: ProjectSchema }));
@@ -0,0 +1,32 @@
1
+ import { z } from 'zod';
2
+ import { REMINDER_TYPES, ReminderBaseSchema } from '../sync/resources/reminders.js';
3
+ import { DueDateSchema } from '../tasks/types.js';
4
+ import { BaseWebhookEnvelopeShape } from './envelope.js';
5
+ /**
6
+ * Enum-like object of reminder (`reminder:*`) webhook event names. Single
7
+ * source of truth for the discriminator values — `REMINDER_WEBHOOK_EVENTS`
8
+ * and every `z.literal()` below derive from it.
9
+ */
10
+ export const ReminderWebhookEventEnum = {
11
+ Fired: 'reminder:fired',
12
+ };
13
+ /** Webhook events that carry a fired-reminder as their `eventData`. */
14
+ export const REMINDER_WEBHOOK_EVENTS = [
15
+ ReminderWebhookEventEnum.Fired,
16
+ ];
17
+ /**
18
+ * A fired-reminder notification as delivered in a webhook payload.
19
+ *
20
+ * `reminder:fired` carries a subset of the full Reminder record (closer
21
+ * to a fired-notification projection), so it doesn't line up with any of
22
+ * the {@link Reminder} discriminated variants directly. This schema
23
+ * reuses {@link ReminderBaseSchema} for the common identity fields and
24
+ * adds the fields always present on a fired notification.
25
+ */
26
+ export const WebhookFiredReminderSchema = ReminderBaseSchema.extend({
27
+ type: z.enum(REMINDER_TYPES),
28
+ isUrgent: z.boolean(),
29
+ minuteOffset: z.number().int().nullable(),
30
+ due: DueDateSchema.nullable(),
31
+ });
32
+ export const ReminderFiredPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(ReminderWebhookEventEnum.Fired), eventData: WebhookFiredReminderSchema }));
@@ -0,0 +1,50 @@
1
+ import { z } from 'zod';
2
+ import { getSectionUrl } from '../../utils/url-helpers.js';
3
+ import { SectionBaseSchema } from '../sections/types.js';
4
+ import { BaseWebhookEnvelopeShape } from './envelope.js';
5
+ /**
6
+ * Enum-like object of section (`section:*`) webhook event names. Single
7
+ * source of truth for the discriminator values — `SECTION_WEBHOOK_EVENTS`
8
+ * and every `z.literal()` below derive from it.
9
+ */
10
+ export const SectionWebhookEventEnum = {
11
+ Added: 'section:added',
12
+ Updated: 'section:updated',
13
+ Deleted: 'section:deleted',
14
+ Archived: 'section:archived',
15
+ Unarchived: 'section:unarchived',
16
+ };
17
+ /** Webhook events that carry a section as their `eventData`. */
18
+ export const SECTION_WEBHOOK_EVENTS = [
19
+ SectionWebhookEventEnum.Added,
20
+ SectionWebhookEventEnum.Updated,
21
+ SectionWebhookEventEnum.Deleted,
22
+ SectionWebhookEventEnum.Archived,
23
+ SectionWebhookEventEnum.Unarchived,
24
+ ];
25
+ /**
26
+ * A section as delivered in a webhook payload.
27
+ *
28
+ * Reuses {@link SectionBaseSchema} and overrides `updatedAt` to tolerate
29
+ * payloads that deliver it as `null` or omit the key entirely — tombstones
30
+ * and never-updated sections come through without an `updated_at` value.
31
+ * The result is normalised to `Date | null` so consumers don't have to
32
+ * handle three shapes. `description` is similarly tolerated (older webhook
33
+ * payloads may omit it) and normalised to `string | null`. Surfaces the
34
+ * computed `url` so the exposed shape matches {@link Section}.
35
+ */
36
+ export const WebhookSectionSchema = SectionBaseSchema.extend({
37
+ updatedAt: z.coerce
38
+ .date()
39
+ .nullish()
40
+ .transform((value) => value !== null && value !== void 0 ? value : null),
41
+ description: z
42
+ .string()
43
+ .nullish()
44
+ .transform((value) => value !== null && value !== void 0 ? value : null),
45
+ }).transform((data) => (Object.assign(Object.assign({}, data), { url: getSectionUrl(data.id, data.name) })));
46
+ export const SectionAddedPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(SectionWebhookEventEnum.Added), eventData: WebhookSectionSchema }));
47
+ export const SectionUpdatedPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(SectionWebhookEventEnum.Updated), eventData: WebhookSectionSchema }));
48
+ export const SectionDeletedPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(SectionWebhookEventEnum.Deleted), eventData: WebhookSectionSchema }));
49
+ export const SectionArchivedPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(SectionWebhookEventEnum.Archived), eventData: WebhookSectionSchema }));
50
+ export const SectionUnarchivedPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(SectionWebhookEventEnum.Unarchived), eventData: WebhookSectionSchema }));
@@ -0,0 +1,65 @@
1
+ import { z } from 'zod';
2
+ import { TaskSchema } from '../tasks/types.js';
3
+ import { BaseWebhookEnvelopeShape } from './envelope.js';
4
+ /**
5
+ * Enum-like object of task (`item:*`) webhook event names. Single source of
6
+ * truth for the discriminator values — `TASK_WEBHOOK_EVENTS` and every
7
+ * `z.literal()` below derive from it.
8
+ */
9
+ export const TaskWebhookEventEnum = {
10
+ Added: 'item:added',
11
+ Updated: 'item:updated',
12
+ Completed: 'item:completed',
13
+ Uncompleted: 'item:uncompleted',
14
+ Deleted: 'item:deleted',
15
+ };
16
+ /**
17
+ * Webhook events that carry a {@link Task} as their `eventData`.
18
+ *
19
+ * The on-the-wire event names remain `item:*` for historical reasons; the
20
+ * SDK types call them `Task*` to match the rest of the public API where the
21
+ * resource is named `Task`.
22
+ */
23
+ export const TASK_WEBHOOK_EVENTS = [
24
+ TaskWebhookEventEnum.Added,
25
+ TaskWebhookEventEnum.Updated,
26
+ TaskWebhookEventEnum.Completed,
27
+ TaskWebhookEventEnum.Uncompleted,
28
+ TaskWebhookEventEnum.Deleted,
29
+ ];
30
+ /**
31
+ * Possible values for the `updateIntent` field on `item:updated`'s
32
+ * `eventDataExtra`. `item_updated` is the default; the others narrow the
33
+ * reason for the update (for example, a recurring completion or a change of
34
+ * assignee).
35
+ *
36
+ * @see https://developer.todoist.com/sync/v1/#webhooks (Events Extra)
37
+ */
38
+ export const UPDATE_INTENTS = [
39
+ 'item_updated',
40
+ 'item_completed',
41
+ 'item_uncompleted',
42
+ 'responsible_uid_changed',
43
+ ];
44
+ /**
45
+ * An unrecognised value from a future backend release degrades gracefully to
46
+ * `'item_updated'` rather than crashing the whole payload parse.
47
+ */
48
+ export const UpdateIntentSchema = z.enum(UPDATE_INTENTS).catch('item_updated');
49
+ /**
50
+ * Extra info delivered alongside an `item:updated` event when the initiator
51
+ * is the acting user. Contains the pre-update task state plus the reason for
52
+ * the update — useful for diffing or for distinguishing manual edits from
53
+ * recurring-task completions.
54
+ *
55
+ * @see https://developer.todoist.com/sync/v1/#webhooks (Events Extra)
56
+ */
57
+ export const TaskUpdatedExtraSchema = z.object({
58
+ oldItem: TaskSchema,
59
+ updateIntent: UpdateIntentSchema,
60
+ });
61
+ export const TaskAddedPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(TaskWebhookEventEnum.Added), eventData: TaskSchema }));
62
+ export const TaskUpdatedPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(TaskWebhookEventEnum.Updated), eventData: TaskSchema, eventDataExtra: TaskUpdatedExtraSchema.optional() }));
63
+ export const TaskCompletedPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(TaskWebhookEventEnum.Completed), eventData: TaskSchema }));
64
+ export const TaskUncompletedPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(TaskWebhookEventEnum.Uncompleted), eventData: TaskSchema }));
65
+ export const TaskDeletedPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(TaskWebhookEventEnum.Deleted), eventData: TaskSchema }));
@@ -0,0 +1,52 @@
1
+ import { z } from 'zod';
2
+ import { WebhookEventSchema } from '../apps/types.js';
3
+ import { CommentAddedPayloadSchema, CommentDeletedPayloadSchema, CommentUpdatedPayloadSchema, } from './comments.js';
4
+ import { FilterAddedPayloadSchema, FilterDeletedPayloadSchema, FilterUpdatedPayloadSchema, } from './filters.js';
5
+ import { LabelAddedPayloadSchema, LabelDeletedPayloadSchema, LabelUpdatedPayloadSchema, } from './labels.js';
6
+ import { ProjectAddedPayloadSchema, ProjectArchivedPayloadSchema, ProjectDeletedPayloadSchema, ProjectUnarchivedPayloadSchema, ProjectUpdatedPayloadSchema, } from './projects.js';
7
+ import { ReminderFiredPayloadSchema } from './reminders.js';
8
+ import { SectionAddedPayloadSchema, SectionArchivedPayloadSchema, SectionDeletedPayloadSchema, SectionUnarchivedPayloadSchema, SectionUpdatedPayloadSchema, } from './sections.js';
9
+ import { TaskAddedPayloadSchema, TaskCompletedPayloadSchema, TaskDeletedPayloadSchema, TaskUncompletedPayloadSchema, TaskUpdatedPayloadSchema, } from './tasks.js';
10
+ /**
11
+ * Wrapper schema for an incoming webhook payload.
12
+ *
13
+ * The backend sends snake_case keys and uses the public event form
14
+ * (`item:added`) in the `event_name` field, so consumers using
15
+ * `parseWebhookPayload` receive camelCase fields directly.
16
+ *
17
+ * Every {@link WebhookEvent} is typed today: `item:*` events carry a parsed
18
+ * {@link Task}; `note:*` events carry a parsed comment (item-comment or
19
+ * project-comment); `label:*` events carry a parsed label; `project:*`
20
+ * events carry a parsed {@link Project} (personal or workspace);
21
+ * `section:*` events carry a parsed {@link WebhookSection}; `filter:*`
22
+ * events carry a parsed {@link Filter}; `reminder:fired` carries a parsed
23
+ * {@link WebhookFiredReminder}.
24
+ */
25
+ export const WebhookPayloadSchema = z.discriminatedUnion('eventName', [
26
+ TaskAddedPayloadSchema,
27
+ TaskUpdatedPayloadSchema,
28
+ TaskCompletedPayloadSchema,
29
+ TaskUncompletedPayloadSchema,
30
+ TaskDeletedPayloadSchema,
31
+ CommentAddedPayloadSchema,
32
+ CommentUpdatedPayloadSchema,
33
+ CommentDeletedPayloadSchema,
34
+ LabelAddedPayloadSchema,
35
+ LabelUpdatedPayloadSchema,
36
+ LabelDeletedPayloadSchema,
37
+ ProjectAddedPayloadSchema,
38
+ ProjectUpdatedPayloadSchema,
39
+ ProjectDeletedPayloadSchema,
40
+ ProjectArchivedPayloadSchema,
41
+ ProjectUnarchivedPayloadSchema,
42
+ SectionAddedPayloadSchema,
43
+ SectionUpdatedPayloadSchema,
44
+ SectionDeletedPayloadSchema,
45
+ SectionArchivedPayloadSchema,
46
+ SectionUnarchivedPayloadSchema,
47
+ FilterAddedPayloadSchema,
48
+ FilterUpdatedPayloadSchema,
49
+ FilterDeletedPayloadSchema,
50
+ ReminderFiredPayloadSchema,
51
+ ]);
52
+ export { WebhookEventSchema };
@@ -0,0 +1,2 @@
1
+ export * from './types.js';
2
+ export * from './requests.js';
@@ -0,0 +1 @@
1
+ export {};