@doist/todoist-sdk 0.0.1 → 8.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 (340) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +194 -29
  3. package/dist/cjs/authentication.js +204 -0
  4. package/dist/cjs/consts/endpoints.js +141 -0
  5. package/dist/cjs/index.js +20 -0
  6. package/dist/cjs/package.json +1 -0
  7. package/dist/cjs/test-utils/asserts.js +11 -0
  8. package/dist/cjs/test-utils/msw-setup.js +97 -0
  9. package/dist/cjs/test-utils/obsidian-fetch-adapter.js +53 -0
  10. package/dist/cjs/test-utils/test-defaults.js +240 -0
  11. package/dist/cjs/todoist-api.js +2623 -0
  12. package/dist/cjs/transport/fetch-with-retry.js +206 -0
  13. package/dist/cjs/transport/http-client.js +133 -0
  14. package/dist/cjs/transport/http-dispatcher.js +72 -0
  15. package/dist/cjs/types/activity/index.js +18 -0
  16. package/dist/cjs/types/activity/requests.js +2 -0
  17. package/dist/cjs/types/activity/types.js +28 -0
  18. package/dist/cjs/types/backups/index.js +18 -0
  19. package/dist/cjs/types/backups/requests.js +2 -0
  20. package/dist/cjs/types/backups/types.js +8 -0
  21. package/dist/cjs/types/comments/index.js +18 -0
  22. package/dist/cjs/types/comments/requests.js +2 -0
  23. package/dist/cjs/types/comments/types.js +60 -0
  24. package/dist/cjs/types/common.js +10 -0
  25. package/dist/cjs/types/emails/index.js +17 -0
  26. package/dist/cjs/types/emails/requests.js +5 -0
  27. package/dist/cjs/types/errors.js +29 -0
  28. package/dist/cjs/types/folders/index.js +17 -0
  29. package/dist/cjs/types/folders/requests.js +2 -0
  30. package/dist/cjs/types/http.js +24 -0
  31. package/dist/cjs/types/id-mappings/index.js +18 -0
  32. package/dist/cjs/types/id-mappings/requests.js +20 -0
  33. package/dist/cjs/types/id-mappings/types.js +12 -0
  34. package/dist/cjs/types/index.js +36 -0
  35. package/dist/cjs/types/insights/index.js +18 -0
  36. package/dist/cjs/types/insights/requests.js +2 -0
  37. package/dist/cjs/types/insights/types.js +84 -0
  38. package/dist/cjs/types/labels/index.js +18 -0
  39. package/dist/cjs/types/labels/requests.js +2 -0
  40. package/dist/cjs/types/labels/types.js +11 -0
  41. package/dist/cjs/types/productivity/index.js +17 -0
  42. package/dist/cjs/types/productivity/types.js +67 -0
  43. package/dist/cjs/types/projects/index.js +18 -0
  44. package/dist/cjs/types/projects/requests.js +2 -0
  45. package/dist/cjs/types/projects/types.js +56 -0
  46. package/dist/cjs/types/reminders/index.js +17 -0
  47. package/dist/cjs/types/reminders/requests.js +95 -0
  48. package/dist/cjs/types/sections/index.js +18 -0
  49. package/dist/cjs/types/sections/requests.js +2 -0
  50. package/dist/cjs/types/sections/types.js +22 -0
  51. package/dist/cjs/types/sync/commands/calendars.js +2 -0
  52. package/dist/cjs/types/sync/commands/filters.js +2 -0
  53. package/dist/cjs/types/sync/commands/folders.js +2 -0
  54. package/dist/cjs/types/sync/commands/index.js +35 -0
  55. package/dist/cjs/types/sync/commands/labels.js +5 -0
  56. package/dist/cjs/types/sync/commands/notes.js +2 -0
  57. package/dist/cjs/types/sync/commands/notifications.js +2 -0
  58. package/dist/cjs/types/sync/commands/others.js +2 -0
  59. package/dist/cjs/types/sync/commands/project-view-options.js +2 -0
  60. package/dist/cjs/types/sync/commands/projects.js +2 -0
  61. package/dist/cjs/types/sync/commands/reminders.js +2 -0
  62. package/dist/cjs/types/sync/commands/sections.js +2 -0
  63. package/dist/cjs/types/sync/commands/shared.js +20 -0
  64. package/dist/cjs/types/sync/commands/sharing.js +2 -0
  65. package/dist/cjs/types/sync/commands/tasks.js +2 -0
  66. package/dist/cjs/types/sync/commands/view-options.js +2 -0
  67. package/dist/cjs/types/sync/commands/workspace-filters.js +2 -0
  68. package/dist/cjs/types/sync/commands/workspace-goals.js +2 -0
  69. package/dist/cjs/types/sync/commands/workspaces.js +2 -0
  70. package/dist/cjs/types/sync/index.js +22 -0
  71. package/dist/cjs/types/sync/request.js +2 -0
  72. package/dist/cjs/types/sync/resource-types.js +40 -0
  73. package/dist/cjs/types/sync/resources/calendars.js +31 -0
  74. package/dist/cjs/types/sync/resources/collaborators.js +25 -0
  75. package/dist/cjs/types/sync/resources/completed-info.js +30 -0
  76. package/dist/cjs/types/sync/resources/filters.js +16 -0
  77. package/dist/cjs/types/sync/resources/folders.js +14 -0
  78. package/dist/cjs/types/sync/resources/index.js +33 -0
  79. package/dist/cjs/types/sync/resources/live-notifications.js +39 -0
  80. package/dist/cjs/types/sync/resources/notes.js +23 -0
  81. package/dist/cjs/types/sync/resources/reminders.js +50 -0
  82. package/dist/cjs/types/sync/resources/suggestions.js +42 -0
  83. package/dist/cjs/types/sync/resources/tooltips.js +10 -0
  84. package/dist/cjs/types/sync/resources/user-plan-limits.js +24 -0
  85. package/dist/cjs/types/sync/resources/user-settings.js +42 -0
  86. package/dist/cjs/types/sync/resources/user.js +120 -0
  87. package/dist/cjs/types/sync/resources/view-options.js +83 -0
  88. package/dist/cjs/types/sync/resources/workspace-filters.js +21 -0
  89. package/dist/cjs/types/sync/resources/workspace-goals.js +32 -0
  90. package/dist/cjs/types/sync/resources/workspaces.js +73 -0
  91. package/dist/cjs/types/sync/response.js +2 -0
  92. package/dist/cjs/types/sync/user-preferences.js +71 -0
  93. package/dist/cjs/types/tasks/index.js +18 -0
  94. package/dist/cjs/types/tasks/requests.js +2 -0
  95. package/dist/cjs/types/tasks/types.js +59 -0
  96. package/dist/cjs/types/templates/index.js +17 -0
  97. package/dist/cjs/types/templates/requests.js +2 -0
  98. package/dist/cjs/types/uploads/index.js +17 -0
  99. package/dist/cjs/types/uploads/requests.js +2 -0
  100. package/dist/cjs/types/users/index.js +17 -0
  101. package/dist/cjs/types/users/types.js +51 -0
  102. package/dist/cjs/types/workspaces/index.js +18 -0
  103. package/dist/cjs/types/workspaces/requests.js +2 -0
  104. package/dist/cjs/types/workspaces/types.js +155 -0
  105. package/dist/cjs/utils/activity-helpers.js +58 -0
  106. package/dist/cjs/utils/case-conversion.js +69 -0
  107. package/dist/cjs/utils/colors.js +143 -0
  108. package/dist/cjs/utils/index.js +25 -0
  109. package/dist/cjs/utils/multipart-upload.js +178 -0
  110. package/dist/cjs/utils/processing-helpers.js +18 -0
  111. package/dist/cjs/utils/sanitization.js +116 -0
  112. package/dist/cjs/utils/sync-helpers.js +22 -0
  113. package/dist/cjs/utils/uncompletable-helpers.js +60 -0
  114. package/dist/cjs/utils/url-helpers.js +74 -0
  115. package/dist/cjs/utils/validators.js +141 -0
  116. package/dist/esm/authentication.js +196 -0
  117. package/dist/esm/consts/endpoints.js +122 -0
  118. package/dist/esm/index.js +4 -0
  119. package/dist/esm/test-utils/asserts.js +8 -0
  120. package/dist/esm/test-utils/msw-setup.js +88 -0
  121. package/dist/esm/test-utils/obsidian-fetch-adapter.js +50 -0
  122. package/dist/esm/test-utils/test-defaults.js +237 -0
  123. package/dist/esm/todoist-api.js +2619 -0
  124. package/dist/esm/transport/fetch-with-retry.js +203 -0
  125. package/dist/esm/transport/http-client.js +128 -0
  126. package/dist/esm/transport/http-dispatcher.js +35 -0
  127. package/dist/esm/types/activity/index.js +2 -0
  128. package/dist/esm/types/activity/requests.js +1 -0
  129. package/dist/esm/types/activity/types.js +25 -0
  130. package/dist/esm/types/backups/index.js +2 -0
  131. package/dist/esm/types/backups/requests.js +1 -0
  132. package/dist/esm/types/backups/types.js +5 -0
  133. package/dist/esm/types/comments/index.js +2 -0
  134. package/dist/esm/types/comments/requests.js +1 -0
  135. package/dist/esm/types/comments/types.js +57 -0
  136. package/dist/esm/types/common.js +7 -0
  137. package/dist/esm/types/emails/index.js +1 -0
  138. package/dist/esm/types/emails/requests.js +2 -0
  139. package/dist/esm/types/errors.js +24 -0
  140. package/dist/esm/types/folders/index.js +1 -0
  141. package/dist/esm/types/folders/requests.js +1 -0
  142. package/dist/esm/types/http.js +20 -0
  143. package/dist/esm/types/id-mappings/index.js +2 -0
  144. package/dist/esm/types/id-mappings/requests.js +17 -0
  145. package/dist/esm/types/id-mappings/types.js +9 -0
  146. package/dist/esm/types/index.js +20 -0
  147. package/dist/esm/types/insights/index.js +2 -0
  148. package/dist/esm/types/insights/requests.js +1 -0
  149. package/dist/esm/types/insights/types.js +81 -0
  150. package/dist/esm/types/labels/index.js +2 -0
  151. package/dist/esm/types/labels/requests.js +1 -0
  152. package/dist/esm/types/labels/types.js +8 -0
  153. package/dist/esm/types/productivity/index.js +1 -0
  154. package/dist/esm/types/productivity/types.js +64 -0
  155. package/dist/esm/types/projects/index.js +2 -0
  156. package/dist/esm/types/projects/requests.js +1 -0
  157. package/dist/esm/types/projects/types.js +53 -0
  158. package/dist/esm/types/reminders/index.js +1 -0
  159. package/dist/esm/types/reminders/requests.js +92 -0
  160. package/dist/esm/types/sections/index.js +2 -0
  161. package/dist/esm/types/sections/requests.js +1 -0
  162. package/dist/esm/types/sections/types.js +19 -0
  163. package/dist/esm/types/sync/commands/calendars.js +1 -0
  164. package/dist/esm/types/sync/commands/filters.js +1 -0
  165. package/dist/esm/types/sync/commands/folders.js +1 -0
  166. package/dist/esm/types/sync/commands/index.js +19 -0
  167. package/dist/esm/types/sync/commands/labels.js +2 -0
  168. package/dist/esm/types/sync/commands/notes.js +1 -0
  169. package/dist/esm/types/sync/commands/notifications.js +1 -0
  170. package/dist/esm/types/sync/commands/others.js +1 -0
  171. package/dist/esm/types/sync/commands/project-view-options.js +1 -0
  172. package/dist/esm/types/sync/commands/projects.js +1 -0
  173. package/dist/esm/types/sync/commands/reminders.js +1 -0
  174. package/dist/esm/types/sync/commands/sections.js +1 -0
  175. package/dist/esm/types/sync/commands/shared.js +16 -0
  176. package/dist/esm/types/sync/commands/sharing.js +1 -0
  177. package/dist/esm/types/sync/commands/tasks.js +1 -0
  178. package/dist/esm/types/sync/commands/view-options.js +1 -0
  179. package/dist/esm/types/sync/commands/workspace-filters.js +1 -0
  180. package/dist/esm/types/sync/commands/workspace-goals.js +1 -0
  181. package/dist/esm/types/sync/commands/workspaces.js +1 -0
  182. package/dist/esm/types/sync/index.js +6 -0
  183. package/dist/esm/types/sync/request.js +1 -0
  184. package/dist/esm/types/sync/resource-types.js +37 -0
  185. package/dist/esm/types/sync/resources/calendars.js +28 -0
  186. package/dist/esm/types/sync/resources/collaborators.js +22 -0
  187. package/dist/esm/types/sync/resources/completed-info.js +27 -0
  188. package/dist/esm/types/sync/resources/filters.js +13 -0
  189. package/dist/esm/types/sync/resources/folders.js +11 -0
  190. package/dist/esm/types/sync/resources/index.js +17 -0
  191. package/dist/esm/types/sync/resources/live-notifications.js +36 -0
  192. package/dist/esm/types/sync/resources/notes.js +20 -0
  193. package/dist/esm/types/sync/resources/reminders.js +47 -0
  194. package/dist/esm/types/sync/resources/suggestions.js +39 -0
  195. package/dist/esm/types/sync/resources/tooltips.js +7 -0
  196. package/dist/esm/types/sync/resources/user-plan-limits.js +21 -0
  197. package/dist/esm/types/sync/resources/user-settings.js +39 -0
  198. package/dist/esm/types/sync/resources/user.js +117 -0
  199. package/dist/esm/types/sync/resources/view-options.js +80 -0
  200. package/dist/esm/types/sync/resources/workspace-filters.js +18 -0
  201. package/dist/esm/types/sync/resources/workspace-goals.js +29 -0
  202. package/dist/esm/types/sync/resources/workspaces.js +70 -0
  203. package/dist/esm/types/sync/response.js +1 -0
  204. package/dist/esm/types/sync/user-preferences.js +68 -0
  205. package/dist/esm/types/tasks/index.js +2 -0
  206. package/dist/esm/types/tasks/requests.js +1 -0
  207. package/dist/esm/types/tasks/types.js +56 -0
  208. package/dist/esm/types/templates/index.js +1 -0
  209. package/dist/esm/types/templates/requests.js +1 -0
  210. package/dist/esm/types/uploads/index.js +1 -0
  211. package/dist/esm/types/uploads/requests.js +1 -0
  212. package/dist/esm/types/users/index.js +1 -0
  213. package/dist/esm/types/users/types.js +48 -0
  214. package/dist/esm/types/workspaces/index.js +2 -0
  215. package/dist/esm/types/workspaces/requests.js +1 -0
  216. package/dist/esm/types/workspaces/types.js +152 -0
  217. package/dist/esm/utils/activity-helpers.js +53 -0
  218. package/dist/esm/utils/case-conversion.js +61 -0
  219. package/dist/esm/utils/colors.js +139 -0
  220. package/dist/esm/utils/index.js +4 -0
  221. package/dist/esm/utils/multipart-upload.js +142 -0
  222. package/dist/esm/utils/processing-helpers.js +12 -0
  223. package/dist/esm/utils/sanitization.js +112 -0
  224. package/dist/esm/utils/sync-helpers.js +19 -0
  225. package/dist/esm/utils/uncompletable-helpers.js +54 -0
  226. package/dist/esm/utils/url-helpers.js +68 -0
  227. package/dist/esm/utils/validators.js +132 -0
  228. package/dist/types/authentication.d.ts +158 -0
  229. package/dist/types/consts/endpoints.d.ts +81 -0
  230. package/dist/types/index.d.ts +4 -0
  231. package/dist/types/test-utils/asserts.d.ts +1 -0
  232. package/dist/types/test-utils/msw-setup.d.ts +33 -0
  233. package/dist/types/test-utils/obsidian-fetch-adapter.d.ts +29 -0
  234. package/dist/types/test-utils/test-defaults.d.ts +261 -0
  235. package/dist/types/todoist-api.d.ts +1018 -0
  236. package/dist/types/transport/fetch-with-retry.d.ts +12 -0
  237. package/dist/types/transport/http-client.d.ts +16 -0
  238. package/dist/types/transport/http-dispatcher.d.ts +3 -0
  239. package/dist/types/types/activity/index.d.ts +2 -0
  240. package/dist/types/types/activity/requests.d.ts +85 -0
  241. package/dist/types/types/activity/types.d.ts +49 -0
  242. package/dist/types/types/backups/index.d.ts +2 -0
  243. package/dist/types/types/backups/requests.d.ts +16 -0
  244. package/dist/types/types/backups/types.d.ts +7 -0
  245. package/dist/types/types/comments/index.d.ts +2 -0
  246. package/dist/types/types/comments/requests.d.ts +64 -0
  247. package/dist/types/types/comments/types.d.ts +141 -0
  248. package/dist/types/types/common.d.ts +13 -0
  249. package/dist/types/types/emails/index.d.ts +1 -0
  250. package/dist/types/types/emails/requests.d.ts +30 -0
  251. package/dist/types/types/errors.d.ts +12 -0
  252. package/dist/types/types/folders/index.d.ts +1 -0
  253. package/dist/types/types/folders/requests.d.ts +20 -0
  254. package/dist/types/types/http.d.ts +85 -0
  255. package/dist/types/types/id-mappings/index.d.ts +2 -0
  256. package/dist/types/types/id-mappings/requests.d.ts +28 -0
  257. package/dist/types/types/id-mappings/types.d.ts +13 -0
  258. package/dist/types/types/index.d.ts +20 -0
  259. package/dist/types/types/insights/index.d.ts +2 -0
  260. package/dist/types/types/insights/requests.d.ts +26 -0
  261. package/dist/types/types/insights/types.d.ts +186 -0
  262. package/dist/types/types/labels/index.d.ts +2 -0
  263. package/dist/types/types/labels/requests.d.ts +75 -0
  264. package/dist/types/types/labels/types.d.ts +13 -0
  265. package/dist/types/types/productivity/index.d.ts +1 -0
  266. package/dist/types/types/productivity/types.d.ts +115 -0
  267. package/dist/types/types/projects/index.d.ts +2 -0
  268. package/dist/types/types/projects/requests.d.ts +169 -0
  269. package/dist/types/types/projects/types.d.ts +201 -0
  270. package/dist/types/types/reminders/index.d.ts +1 -0
  271. package/dist/types/types/reminders/requests.d.ts +205 -0
  272. package/dist/types/types/sections/index.d.ts +2 -0
  273. package/dist/types/types/sections/requests.d.ts +41 -0
  274. package/dist/types/types/sections/types.d.ts +44 -0
  275. package/dist/types/types/sync/commands/calendars.d.ts +14 -0
  276. package/dist/types/types/sync/commands/filters.d.ts +22 -0
  277. package/dist/types/types/sync/commands/folders.d.ts +18 -0
  278. package/dist/types/types/sync/commands/index.d.ts +171 -0
  279. package/dist/types/types/sync/commands/labels.d.ts +32 -0
  280. package/dist/types/types/sync/commands/notes.d.ts +27 -0
  281. package/dist/types/types/sync/commands/notifications.d.ts +10 -0
  282. package/dist/types/types/sync/commands/others.d.ts +39 -0
  283. package/dist/types/types/sync/commands/project-view-options.d.ts +14 -0
  284. package/dist/types/types/sync/commands/projects.d.ts +90 -0
  285. package/dist/types/types/sync/commands/reminders.d.ts +51 -0
  286. package/dist/types/types/sync/commands/sections.d.ts +31 -0
  287. package/dist/types/types/sync/commands/shared.d.ts +51 -0
  288. package/dist/types/types/sync/commands/sharing.d.ts +16 -0
  289. package/dist/types/types/sync/commands/tasks.d.ts +78 -0
  290. package/dist/types/types/sync/commands/view-options.d.ts +15 -0
  291. package/dist/types/types/sync/commands/workspace-filters.d.ts +23 -0
  292. package/dist/types/types/sync/commands/workspace-goals.d.ts +24 -0
  293. package/dist/types/types/sync/commands/workspaces.d.ts +79 -0
  294. package/dist/types/types/sync/index.d.ts +6 -0
  295. package/dist/types/types/sync/request.d.ts +7 -0
  296. package/dist/types/types/sync/resource-types.d.ts +5 -0
  297. package/dist/types/types/sync/resources/calendars.d.ts +38 -0
  298. package/dist/types/types/sync/resources/collaborators.d.ts +28 -0
  299. package/dist/types/types/sync/resources/completed-info.d.ts +33 -0
  300. package/dist/types/types/sync/resources/filters.d.ts +12 -0
  301. package/dist/types/types/sync/resources/folders.d.ts +10 -0
  302. package/dist/types/types/sync/resources/index.d.ts +17 -0
  303. package/dist/types/types/sync/resources/live-notifications.d.ts +32 -0
  304. package/dist/types/types/sync/resources/notes.d.ts +34 -0
  305. package/dist/types/types/sync/resources/reminders.d.ts +126 -0
  306. package/dist/types/types/sync/resources/suggestions.d.ts +96 -0
  307. package/dist/types/types/sync/resources/tooltips.d.ts +6 -0
  308. package/dist/types/types/sync/resources/user-plan-limits.d.ts +41 -0
  309. package/dist/types/types/sync/resources/user-settings.d.ts +40 -0
  310. package/dist/types/types/sync/resources/user.d.ts +134 -0
  311. package/dist/types/types/sync/resources/view-options.d.ts +169 -0
  312. package/dist/types/types/sync/resources/workspace-filters.d.ts +17 -0
  313. package/dist/types/types/sync/resources/workspace-goals.d.ts +29 -0
  314. package/dist/types/types/sync/resources/workspaces.d.ts +142 -0
  315. package/dist/types/types/sync/response.d.ts +51 -0
  316. package/dist/types/types/sync/user-preferences.d.ts +39 -0
  317. package/dist/types/types/tasks/index.d.ts +2 -0
  318. package/dist/types/types/tasks/requests.d.ts +197 -0
  319. package/dist/types/types/tasks/types.d.ts +162 -0
  320. package/dist/types/types/templates/index.d.ts +1 -0
  321. package/dist/types/types/templates/requests.d.ts +92 -0
  322. package/dist/types/types/uploads/index.d.ts +1 -0
  323. package/dist/types/types/uploads/requests.d.ts +32 -0
  324. package/dist/types/types/users/index.d.ts +1 -0
  325. package/dist/types/types/users/types.d.ts +66 -0
  326. package/dist/types/types/workspaces/index.d.ts +2 -0
  327. package/dist/types/types/workspaces/requests.d.ts +260 -0
  328. package/dist/types/types/workspaces/types.d.ts +267 -0
  329. package/dist/types/utils/activity-helpers.d.ts +28 -0
  330. package/dist/types/utils/case-conversion.d.ts +12 -0
  331. package/dist/types/utils/colors.d.ts +197 -0
  332. package/dist/types/utils/index.d.ts +4 -0
  333. package/dist/types/utils/multipart-upload.d.ts +54 -0
  334. package/dist/types/utils/processing-helpers.d.ts +1 -0
  335. package/dist/types/utils/sanitization.d.ts +35 -0
  336. package/dist/types/utils/sync-helpers.d.ts +17 -0
  337. package/dist/types/utils/uncompletable-helpers.d.ts +30 -0
  338. package/dist/types/utils/url-helpers.d.ts +32 -0
  339. package/dist/types/utils/validators.d.ts +1404 -0
  340. package/package.json +99 -8
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Doist
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,45 +1,210 @@
1
- # @doist/todoist-sdk
1
+ # Todoist SDK
2
2
 
3
- ## ⚠️ IMPORTANT NOTICE ⚠️
3
+ The official TypeScript SDK for the Todoist REST API.
4
4
 
5
- **This package is created solely for the purpose of setting up OIDC (OpenID Connect) trusted publishing with npm.**
5
+ ## Installation
6
6
 
7
- This is **NOT** a functional package and contains **NO** code or functionality beyond the OIDC setup configuration.
7
+ Requires Node 20.18.1+.
8
8
 
9
- ## Purpose
9
+ ```
10
+ npm install @doist/todoist-sdk
11
+ ```
10
12
 
11
- This package exists to:
12
- 1. Configure OIDC trusted publishing for the package name `@doist/todoist-sdk`
13
- 2. Enable secure, token-less publishing from CI/CD workflows
14
- 3. Establish provenance for packages published under this name
13
+ ### Usage
15
14
 
16
- ## What is OIDC Trusted Publishing?
15
+ An example of initializing the API client and fetching a user's tasks:
17
16
 
18
- OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
17
+ ```typescript
18
+ import { TodoistApi } from '@doist/todoist-sdk'
19
19
 
20
- ## Setup Instructions
20
+ const api = new TodoistApi('YOURTOKEN')
21
21
 
22
- To properly configure OIDC trusted publishing for this package:
22
+ api.getTasks()
23
+ .then((tasks) => console.log(tasks))
24
+ .catch((error) => console.log(error))
25
+ ```
23
26
 
24
- 1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
25
- 2. Configure the trusted publisher (e.g., GitHub Actions)
26
- 3. Specify the repository and workflow that should be allowed to publish
27
- 4. Use the configured workflow to publish your actual package
27
+ ### Documentation
28
28
 
29
- ## DO NOT USE THIS PACKAGE
29
+ For more detailed reference documentation, have a look at the [Todoist API v1 Documentation](https://todoist.com/api/v1/docs).
30
30
 
31
- This package is a placeholder for OIDC configuration only. It:
32
- - Contains no executable code
33
- - Provides no functionality
34
- - Should not be installed as a dependency
35
- - Exists only for administrative purposes
31
+ ### Migration Guide
36
32
 
37
- ## More Information
33
+ If you're migrating from an older version of the Todoist API (v9), please refer to the [official migration guide](https://todoist.com/api/v1/docs#tag/Migrating-from-v9) for detailed information about the changes and breaking updates.
38
34
 
39
- For more details about npm's trusted publishing feature, see:
40
- - [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
41
- - [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
35
+ Key changes in v1 include:
42
36
 
43
- ---
37
+ - Updated endpoint structure
38
+ - New pagination system
39
+ - Unified error response format
40
+ - Object renames (e.g., items → tasks, notes → comments)
41
+ - URL renames and endpoint signature changes
44
42
 
45
- **Maintained for OIDC setup purposes only**
43
+ ## Custom HTTP Clients
44
+
45
+ The Todoist API client supports custom HTTP implementations to enable usage in environments with specific networking requirements, such as:
46
+
47
+ - **Obsidian plugins** - Desktop app with strict CORS policies
48
+ - **Browser extensions** - Custom HTTP APIs with different security models
49
+ - **Electron apps** - Requests routed through IPC layer
50
+ - **React Native** - Different networking stack
51
+ - **Enterprise environments** - Proxy configuration, custom headers, or certificate handling
52
+
53
+ ### Basic Usage
54
+
55
+ ```typescript
56
+ import { TodoistApi } from '@doist/todoist-sdk'
57
+
58
+ // Using the new options-based constructor
59
+ const api = new TodoistApi('YOURTOKEN', {
60
+ baseUrl: 'https://custom-api.example.com', // optional
61
+ customFetch: myCustomFetch, // your custom fetch implementation
62
+ })
63
+
64
+ // Legacy constructor (deprecated but supported)
65
+ const apiLegacy = new TodoistApi('YOURTOKEN', 'https://custom-api.example.com')
66
+ ```
67
+
68
+ ### Custom Fetch Interface
69
+
70
+ Your custom fetch function must implement this interface:
71
+
72
+ ```typescript
73
+ type CustomFetch = (
74
+ url: string,
75
+ options?: RequestInit & { timeout?: number },
76
+ ) => Promise<CustomFetchResponse>
77
+
78
+ type CustomFetchResponse = {
79
+ ok: boolean
80
+ status: number
81
+ statusText: string
82
+ headers: Record<string, string>
83
+ text(): Promise<string>
84
+ json(): Promise<unknown>
85
+ }
86
+ ```
87
+
88
+ ### OAuth with Custom Fetch
89
+
90
+ OAuth authentication functions (`getAuthToken`, `revokeAuthToken`, `revokeToken`) support custom fetch through an options object:
91
+
92
+ ```typescript
93
+ // New options-based usage
94
+ const { accessToken } = await getAuthToken(args, {
95
+ baseUrl: 'https://custom-auth.example.com',
96
+ customFetch: myCustomFetch,
97
+ })
98
+
99
+ await revokeToken(args, {
100
+ customFetch: myCustomFetch,
101
+ })
102
+
103
+ // Legacy usage (deprecated)
104
+ const { accessToken } = await getAuthToken(args, baseUrl)
105
+ ```
106
+
107
+ ### Important Notes
108
+
109
+ - All existing transforms (snake_case ↔ camelCase) work automatically with custom fetch
110
+ - Retry logic and error handling are preserved
111
+ - File uploads work with custom fetch implementations
112
+ - The custom fetch function should handle FormData for multipart uploads
113
+ - Timeout parameter is optional and up to your custom implementation
114
+
115
+ ## Development and Testing
116
+
117
+ Instead of having an example app in the repository to assist development and testing, we have included [ts-node](https://github.com/TypeStrong/ts-node) as a dev dependency. This allows us to have a scratch file locally that can import and utilize the API while developing or reviewing pull requests without having to manage a separate app project.
118
+
119
+ - `npm install`
120
+ - Add a file named `scratch.ts` in the `src` folder.
121
+ - Configure your IDE to run the scratch file with `ts-node` (instructions for [VSCode](https://medium.com/@dupski/debug-typescript-in-vs-code-without-compiling-using-ts-node-9d1f4f9a94a), [WebStorm](https://www.jetbrains.com/help/webstorm/running-and-debugging-typescript.html#ws_ts_run_debug_server_side_ts_node)), or you can optionally run ts-node in a terminal using instructions [here](https://github.com/TypeStrong/ts-node) (`npx ts-node ./src/scratch.ts` should be enough).
122
+ - Import and call the relevant modules and run the scratch file.
123
+
124
+ Example scratch.ts file:
125
+
126
+ ```
127
+ /* eslint-disable no-console */
128
+ import { TodoistApi } from './todoist-api'
129
+
130
+ const token = 'YOURTOKEN'
131
+ const api = new TodoistApi(token)
132
+
133
+ api.getProjects()
134
+ .then((projects) => {
135
+ console.log(projects)
136
+ })
137
+ .catch((error) => console.error(error))
138
+ ```
139
+
140
+ ### Local API Requests With .env
141
+
142
+ For live API verification, you can run raw requests with a local token:
143
+
144
+ 1. Copy `.env.example` to `.env`.
145
+ 2. Set `TODOIST_API_TOKEN` in `.env`.
146
+ 3. Run requests with `npm run api:request -- ...`.
147
+ 4. Optional: set `TODOIST_API_BASE_URL` in `.env` (defaults to `https://api.todoist.com`).
148
+
149
+ Examples:
150
+
151
+ ```bash
152
+ npm run api:request -- --path /api/v1/tasks
153
+ npm run api:request -- --method POST --path /api/v1/tasks --body '{"content":"API smoke test"}'
154
+ npm run api:request -- --method POST --path /api/v1/tasks/123 --body '{"due_string":"no date"}'
155
+ npm run api:request -- --path /api/v1/tasks --query '{"project_id":"123","limit":10}'
156
+ ```
157
+
158
+ To see all options:
159
+
160
+ ```bash
161
+ npm run api:request -- --help
162
+ ```
163
+
164
+ ## Releases
165
+
166
+ This project uses [Release Please](https://github.com/googleapis/release-please) to automate releases. Releases are created automatically based on [Conventional Commits](https://www.conventionalcommits.org/).
167
+
168
+ ### For Contributors
169
+
170
+ When making changes, use conventional commit messages:
171
+
172
+ - `feat:` - New features (triggers a minor version bump)
173
+ - `fix:` - Bug fixes (triggers a patch version bump)
174
+ - `feat!:` or `BREAKING CHANGE:` - Breaking changes (triggers a major version bump)
175
+ - `chore:`, `docs:`, `refactor:`, `perf:` - Other changes (included in changelog)
176
+
177
+ Example:
178
+
179
+ ```
180
+ feat: add support for recurring tasks
181
+ fix: resolve issue with date parsing
182
+ feat!: remove deprecated getTask method
183
+ ```
184
+
185
+ ### For Maintainers
186
+
187
+ The release process is fully automated:
188
+
189
+ 1. **Automatic PR Creation**: When commits are merged to `main`, Release Please automatically creates or updates a release PR with:
190
+
191
+ - Updated version in `package.json`
192
+ - Updated `CHANGELOG.md`
193
+ - Aggregated changes since the last release
194
+
195
+ 2. **Review and Merge**: Review the release PR to ensure the version bump and changelog are correct, then merge it.
196
+
197
+ 3. **Automatic Release**: Upon merging the release PR:
198
+ - A GitHub release is automatically created with the new version tag
199
+ - The `publish.yml` workflow is triggered by the tag
200
+ - The package is automatically published to NPM
201
+
202
+ Users of the API client can then update to the new version in their `package.json`.
203
+
204
+ ### Feedback
205
+
206
+ Any feedback, such as bugs, questions, comments, etc. can be reported as _Issues_ in this repository, and will be handled by us in Todoist.
207
+
208
+ ### Contributions
209
+
210
+ We would also love contributions in the form of _Pull requests_ in this repository.
@@ -0,0 +1,204 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PERMISSIONS = void 0;
4
+ exports.getAuthStateParameter = getAuthStateParameter;
5
+ exports.getAuthorizationUrl = getAuthorizationUrl;
6
+ exports.getAuthToken = getAuthToken;
7
+ exports.revokeToken = revokeToken;
8
+ exports.migratePersonalToken = migratePersonalToken;
9
+ const http_client_1 = require("./transport/http-client");
10
+ const uuid_1 = require("uuid");
11
+ const types_1 = require("./types");
12
+ const endpoints_1 = require("./consts/endpoints");
13
+ /** Available OAuth2 permission scopes. */
14
+ exports.PERMISSIONS = [
15
+ 'task:add',
16
+ 'data:read',
17
+ 'data:read_write',
18
+ 'data:delete',
19
+ 'project:delete',
20
+ 'backups:read',
21
+ ];
22
+ /**
23
+ * Creates a Basic Authentication header value from client credentials.
24
+ * @param clientId - The OAuth client ID
25
+ * @param clientSecret - The OAuth client secret
26
+ * @returns The Basic Auth header value (without the 'Basic ' prefix)
27
+ */
28
+ function createBasicAuthHeader(clientId, clientSecret) {
29
+ const credentials = `${clientId}:${clientSecret}`;
30
+ return Buffer.from(credentials).toString('base64');
31
+ }
32
+ /**
33
+ * Generates a random state parameter for OAuth2 authorization.
34
+ * The state parameter helps prevent CSRF attacks.
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * const state = getAuthStateParameter()
39
+ * // Store state in session
40
+ * const authUrl = getAuthorizationUrl(clientId, ['data:read'], state)
41
+ * ```
42
+ *
43
+ * @returns A random UUID v4 string
44
+ */
45
+ function getAuthStateParameter() {
46
+ return (0, uuid_1.v4)();
47
+ }
48
+ /**
49
+ * Generates the authorization URL for the OAuth2 flow.
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * const url = getAuthorizationUrl(
54
+ * 'your-client-id',
55
+ * ['data:read', 'task:add'],
56
+ * state
57
+ * )
58
+ * // Redirect user to url
59
+ * ```
60
+ *
61
+ * @returns The full authorization URL to redirect users to
62
+ * @see https://developer.todoist.com/api/v1/#tag/Authorization/OAuth
63
+ */
64
+ function getAuthorizationUrl({ clientId, permissions, state, baseUrl, }) {
65
+ if (!(permissions === null || permissions === void 0 ? void 0 : permissions.length)) {
66
+ throw new Error('At least one scope value should be passed for permissions.');
67
+ }
68
+ const scope = permissions.join(',');
69
+ return `${(0, endpoints_1.getAuthBaseUri)(baseUrl)}${endpoints_1.ENDPOINT_AUTHORIZATION}?client_id=${clientId}&scope=${scope}&state=${state}`;
70
+ }
71
+ /**
72
+ * Exchanges an authorization code for an access token.
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * const { accessToken } = await getAuthToken({
77
+ * clientId: 'your-client-id',
78
+ * clientSecret: 'your-client-secret',
79
+ * code: authCode
80
+ * })
81
+ * ```
82
+ *
83
+ * @returns The access token response
84
+ * @throws {@link TodoistRequestError} If the token exchange fails
85
+ */
86
+ async function getAuthToken(args, options) {
87
+ var _a;
88
+ if (typeof options === 'string') {
89
+ throw new TypeError('Passing baseUrl as a string is no longer supported. Use an options object instead: getAuthToken(args, { baseUrl })');
90
+ }
91
+ const baseUrl = options === null || options === void 0 ? void 0 : options.baseUrl;
92
+ const customFetch = options === null || options === void 0 ? void 0 : options.customFetch;
93
+ try {
94
+ const response = await (0, http_client_1.request)({
95
+ httpMethod: 'POST',
96
+ baseUri: (0, endpoints_1.getAuthBaseUri)(baseUrl),
97
+ relativePath: endpoints_1.ENDPOINT_GET_TOKEN,
98
+ apiToken: undefined,
99
+ payload: args,
100
+ customFetch,
101
+ });
102
+ if (response.status !== 200 || !((_a = response.data) === null || _a === void 0 ? void 0 : _a.accessToken)) {
103
+ throw new types_1.TodoistRequestError('Authentication token exchange failed.', response.status, response.data);
104
+ }
105
+ return response.data;
106
+ }
107
+ catch (error) {
108
+ // Re-throw with custom message for authentication failures
109
+ const err = error;
110
+ throw new types_1.TodoistRequestError('Authentication token exchange failed.', err.httpStatusCode, err.responseData);
111
+ }
112
+ }
113
+ /**
114
+ * Revokes a token using the RFC 7009 OAuth 2.0 Token Revocation standard.
115
+ *
116
+ * This function uses HTTP Basic Authentication with client credentials and follows
117
+ * the RFC 7009 specification for token revocation.
118
+ *
119
+ * @example
120
+ * ```typescript
121
+ * await revokeToken({
122
+ * clientId: 'your-client-id',
123
+ * clientSecret: 'your-client-secret',
124
+ * token: 'access-token-to-revoke'
125
+ * })
126
+ * ```
127
+ *
128
+ * @returns True if revocation was successful
129
+ * @see https://datatracker.ietf.org/doc/html/rfc7009
130
+ * @see https://developer.todoist.com/api/v1/#tag/Authorization
131
+ */
132
+ async function revokeToken(args, options) {
133
+ if (typeof options === 'string') {
134
+ throw new TypeError('Passing baseUrl as a string is no longer supported. Use an options object instead: revokeToken(args, { baseUrl })');
135
+ }
136
+ const baseUrl = options === null || options === void 0 ? void 0 : options.baseUrl;
137
+ const customFetch = options === null || options === void 0 ? void 0 : options.customFetch;
138
+ const { clientId, clientSecret, token } = args;
139
+ // Create Basic Auth header as per RFC 7009
140
+ const basicAuth = createBasicAuthHeader(clientId, clientSecret);
141
+ const customHeaders = {
142
+ Authorization: `Basic ${basicAuth}`,
143
+ };
144
+ // Request body only contains the token and optional token_type_hint
145
+ const requestBody = {
146
+ token,
147
+ token_type_hint: 'access_token',
148
+ };
149
+ const response = await (0, http_client_1.request)({
150
+ httpMethod: 'POST',
151
+ baseUri: (0, endpoints_1.getSyncBaseUri)(baseUrl),
152
+ relativePath: endpoints_1.ENDPOINT_REVOKE,
153
+ apiToken: undefined,
154
+ payload: requestBody,
155
+ requestId: undefined,
156
+ hasSyncCommands: false,
157
+ customHeaders: customHeaders,
158
+ customFetch,
159
+ });
160
+ return (0, http_client_1.isSuccess)(response);
161
+ }
162
+ /**
163
+ * Migrates a personal API token to an OAuth access token.
164
+ *
165
+ * This allows applications to transition users from personal API tokens
166
+ * to proper OAuth tokens without requiring the user to go through the
167
+ * full OAuth authorization flow.
168
+ *
169
+ * @example
170
+ * ```typescript
171
+ * const { accessToken } = await migratePersonalToken({
172
+ * clientId: 'your-client-id',
173
+ * clientSecret: 'your-client-secret',
174
+ * personalToken: 'user-personal-token',
175
+ * scope: 'data:read_write,data:delete'
176
+ * })
177
+ * ```
178
+ *
179
+ * @returns The new OAuth token response
180
+ * @throws {@link TodoistRequestError} If the migration fails
181
+ */
182
+ async function migratePersonalToken(args, options) {
183
+ var _a;
184
+ const baseUrl = options === null || options === void 0 ? void 0 : options.baseUrl;
185
+ const customFetch = options === null || options === void 0 ? void 0 : options.customFetch;
186
+ try {
187
+ const response = await (0, http_client_1.request)({
188
+ httpMethod: 'POST',
189
+ baseUri: (0, endpoints_1.getSyncBaseUri)(baseUrl),
190
+ relativePath: endpoints_1.ENDPOINT_REST_ACCESS_TOKENS_MIGRATE,
191
+ apiToken: undefined,
192
+ payload: Object.assign(Object.assign({}, args), { scope: args.scope.join(',') }),
193
+ customFetch,
194
+ });
195
+ if (response.status !== 200 || !((_a = response.data) === null || _a === void 0 ? void 0 : _a.accessToken)) {
196
+ throw new types_1.TodoistRequestError('Personal token migration failed.', response.status, response.data);
197
+ }
198
+ return response.data;
199
+ }
200
+ catch (error) {
201
+ const err = error;
202
+ throw new types_1.TodoistRequestError('Personal token migration failed.', err.httpStatusCode, err.responseData);
203
+ }
204
+ }
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ENDPOINT_REST_ID_MAPPINGS = exports.ENDPOINT_REST_EMAILS = exports.ENDPOINT_REST_BACKUPS_DOWNLOAD = exports.ENDPOINT_REST_BACKUPS = exports.ENDPOINT_REST_ACCESS_TOKENS_MIGRATE = exports.ENDPOINT_REST_TEMPLATES_IMPORT_FROM_ID = exports.ENDPOINT_REST_TEMPLATES_IMPORT_FROM_FILE = exports.ENDPOINT_REST_TEMPLATES_CREATE_FROM_FILE = exports.ENDPOINT_REST_TEMPLATES_URL = exports.ENDPOINT_REST_TEMPLATES_FILE = exports.ENDPOINT_REST_TASKS_COMPLETED = exports.ENDPOINT_REST_PROJECTS_MOVE_TO_PERSONAL = exports.ENDPOINT_REST_PROJECTS_MOVE_TO_WORKSPACE = exports.SECTION_UNARCHIVE = exports.SECTION_ARCHIVE = exports.ENDPOINT_REST_PROJECT_JOIN = exports.ENDPOINT_REST_PROJECT_FULL = exports.ENDPOINT_REST_PROJECTS_PERMISSIONS = exports.ENDPOINT_REST_PROJECTS_ARCHIVED_COUNT = exports.PROJECT_UNARCHIVE = exports.PROJECT_ARCHIVE = exports.ENDPOINT_REST_UPLOADS = exports.ENDPOINT_REST_ACTIVITIES = exports.ENDPOINT_REST_PRODUCTIVITY = exports.ENDPOINT_REST_USER = exports.ENDPOINT_REST_PROJECT_COLLABORATORS = exports.ENDPOINT_REST_PROJECTS_ARCHIVED = exports.ENDPOINT_REST_PROJECTS_SEARCH = exports.ENDPOINT_REST_PROJECTS = exports.ENDPOINT_REST_TASK_MOVE = exports.ENDPOINT_REST_TASK_REOPEN = exports.ENDPOINT_REST_TASK_CLOSE = exports.ENDPOINT_REST_LOCATION_REMINDERS = exports.ENDPOINT_REST_REMINDERS = exports.ENDPOINT_REST_COMMENTS = exports.ENDPOINT_REST_LABELS_SHARED_REMOVE = exports.ENDPOINT_REST_LABELS_SHARED_RENAME = exports.ENDPOINT_REST_LABELS_SHARED = exports.ENDPOINT_REST_LABELS_SEARCH = exports.ENDPOINT_REST_LABELS = exports.ENDPOINT_REST_SECTIONS_SEARCH = exports.ENDPOINT_REST_SECTIONS = exports.ENDPOINT_REST_TASKS_COMPLETED_SEARCH = exports.ENDPOINT_REST_TASKS_COMPLETED_BY_DUE_DATE = exports.ENDPOINT_REST_TASKS_COMPLETED_BY_COMPLETION_DATE = exports.ENDPOINT_REST_TASKS_FILTER = exports.ENDPOINT_REST_TASKS = exports.API_BASE_URI = exports.API_VERSION = exports.TODOIST_WEB_URI = void 0;
4
+ exports.ENDPOINT_WORKSPACE_MEMBERS = exports.ENDPOINT_WORKSPACE_USERS = exports.ENDPOINT_WORKSPACE_PLAN_DETAILS = exports.ENDPOINT_WORKSPACE_LOGO = exports.ENDPOINT_WORKSPACE_JOIN = exports.ENDPOINT_WORKSPACE_INVITATIONS_DELETE = exports.ENDPOINT_WORKSPACE_INVITATIONS_ALL = exports.ENDPOINT_WORKSPACE_INVITATIONS = exports.ENDPOINT_REST_WORKSPACES = exports.ENDPOINT_REST_FOLDERS = exports.ENDPOINT_REVOKE = exports.ENDPOINT_GET_TOKEN = exports.ENDPOINT_AUTHORIZATION = exports.ENDPOINT_SYNC = exports.ENDPOINT_SYNC_QUICK_ADD = exports.ENDPOINT_REST_MOVED_IDS = void 0;
5
+ exports.getSyncBaseUri = getSyncBaseUri;
6
+ exports.getAuthBaseUri = getAuthBaseUri;
7
+ exports.getWorkspaceInvitationAcceptEndpoint = getWorkspaceInvitationAcceptEndpoint;
8
+ exports.getWorkspaceInvitationRejectEndpoint = getWorkspaceInvitationRejectEndpoint;
9
+ exports.getProjectInsightsActivityStatsEndpoint = getProjectInsightsActivityStatsEndpoint;
10
+ exports.getProjectInsightsHealthEndpoint = getProjectInsightsHealthEndpoint;
11
+ exports.getProjectInsightsHealthContextEndpoint = getProjectInsightsHealthContextEndpoint;
12
+ exports.getProjectInsightsProgressEndpoint = getProjectInsightsProgressEndpoint;
13
+ exports.getProjectInsightsHealthAnalyzeEndpoint = getProjectInsightsHealthAnalyzeEndpoint;
14
+ exports.getWorkspaceInsightsEndpoint = getWorkspaceInsightsEndpoint;
15
+ exports.getWorkspaceUserTasksEndpoint = getWorkspaceUserTasksEndpoint;
16
+ exports.getWorkspaceInviteUsersEndpoint = getWorkspaceInviteUsersEndpoint;
17
+ exports.getWorkspaceUserEndpoint = getWorkspaceUserEndpoint;
18
+ exports.getWorkspaceActiveProjectsEndpoint = getWorkspaceActiveProjectsEndpoint;
19
+ exports.getWorkspaceArchivedProjectsEndpoint = getWorkspaceArchivedProjectsEndpoint;
20
+ const BASE_URI = 'https://api.todoist.com';
21
+ const TODOIST_URI = 'https://todoist.com';
22
+ exports.TODOIST_WEB_URI = 'https://app.todoist.com/app';
23
+ // The API version is not configurable, to ensure
24
+ // compatibility between the API and the client.
25
+ exports.API_VERSION = 'v1';
26
+ exports.API_BASE_URI = `/api/${exports.API_VERSION}/`;
27
+ const API_AUTHORIZATION_BASE_URI = '/oauth/';
28
+ function getSyncBaseUri(domainBase = BASE_URI) {
29
+ return new URL(exports.API_BASE_URI, domainBase).toString();
30
+ }
31
+ function getAuthBaseUri(domainBase = TODOIST_URI) {
32
+ return new URL(API_AUTHORIZATION_BASE_URI, domainBase).toString();
33
+ }
34
+ exports.ENDPOINT_REST_TASKS = 'tasks';
35
+ exports.ENDPOINT_REST_TASKS_FILTER = exports.ENDPOINT_REST_TASKS + '/filter';
36
+ exports.ENDPOINT_REST_TASKS_COMPLETED_BY_COMPLETION_DATE = exports.ENDPOINT_REST_TASKS + '/completed/by_completion_date';
37
+ exports.ENDPOINT_REST_TASKS_COMPLETED_BY_DUE_DATE = exports.ENDPOINT_REST_TASKS + '/completed/by_due_date';
38
+ exports.ENDPOINT_REST_TASKS_COMPLETED_SEARCH = 'completed/search';
39
+ exports.ENDPOINT_REST_SECTIONS = 'sections';
40
+ exports.ENDPOINT_REST_SECTIONS_SEARCH = exports.ENDPOINT_REST_SECTIONS + '/search';
41
+ exports.ENDPOINT_REST_LABELS = 'labels';
42
+ exports.ENDPOINT_REST_LABELS_SEARCH = exports.ENDPOINT_REST_LABELS + '/search';
43
+ exports.ENDPOINT_REST_LABELS_SHARED = exports.ENDPOINT_REST_LABELS + '/shared';
44
+ exports.ENDPOINT_REST_LABELS_SHARED_RENAME = exports.ENDPOINT_REST_LABELS_SHARED + '/rename';
45
+ exports.ENDPOINT_REST_LABELS_SHARED_REMOVE = exports.ENDPOINT_REST_LABELS_SHARED + '/remove';
46
+ exports.ENDPOINT_REST_COMMENTS = 'comments';
47
+ exports.ENDPOINT_REST_REMINDERS = 'reminders';
48
+ exports.ENDPOINT_REST_LOCATION_REMINDERS = 'location_reminders';
49
+ exports.ENDPOINT_REST_TASK_CLOSE = 'close';
50
+ exports.ENDPOINT_REST_TASK_REOPEN = 'reopen';
51
+ exports.ENDPOINT_REST_TASK_MOVE = 'move';
52
+ exports.ENDPOINT_REST_PROJECTS = 'projects';
53
+ exports.ENDPOINT_REST_PROJECTS_SEARCH = exports.ENDPOINT_REST_PROJECTS + '/search';
54
+ exports.ENDPOINT_REST_PROJECTS_ARCHIVED = exports.ENDPOINT_REST_PROJECTS + '/archived';
55
+ exports.ENDPOINT_REST_PROJECT_COLLABORATORS = 'collaborators';
56
+ exports.ENDPOINT_REST_USER = 'user';
57
+ exports.ENDPOINT_REST_PRODUCTIVITY = exports.ENDPOINT_REST_TASKS + '/completed/stats';
58
+ exports.ENDPOINT_REST_ACTIVITIES = 'activities';
59
+ exports.ENDPOINT_REST_UPLOADS = 'uploads';
60
+ exports.PROJECT_ARCHIVE = 'archive';
61
+ exports.PROJECT_UNARCHIVE = 'unarchive';
62
+ exports.ENDPOINT_REST_PROJECTS_ARCHIVED_COUNT = exports.ENDPOINT_REST_PROJECTS + '/archived/count';
63
+ exports.ENDPOINT_REST_PROJECTS_PERMISSIONS = exports.ENDPOINT_REST_PROJECTS + '/permissions';
64
+ exports.ENDPOINT_REST_PROJECT_FULL = 'full';
65
+ exports.ENDPOINT_REST_PROJECT_JOIN = 'join';
66
+ exports.SECTION_ARCHIVE = 'archive';
67
+ exports.SECTION_UNARCHIVE = 'unarchive';
68
+ exports.ENDPOINT_REST_PROJECTS_MOVE_TO_WORKSPACE = exports.ENDPOINT_REST_PROJECTS + '/move_to_workspace';
69
+ exports.ENDPOINT_REST_PROJECTS_MOVE_TO_PERSONAL = exports.ENDPOINT_REST_PROJECTS + '/move_to_personal';
70
+ exports.ENDPOINT_REST_TASKS_COMPLETED = exports.ENDPOINT_REST_TASKS + '/completed';
71
+ exports.ENDPOINT_REST_TEMPLATES_FILE = 'templates/file';
72
+ exports.ENDPOINT_REST_TEMPLATES_URL = 'templates/url';
73
+ exports.ENDPOINT_REST_TEMPLATES_CREATE_FROM_FILE = 'templates/create_project_from_file';
74
+ exports.ENDPOINT_REST_TEMPLATES_IMPORT_FROM_FILE = 'templates/import_into_project_from_file';
75
+ exports.ENDPOINT_REST_TEMPLATES_IMPORT_FROM_ID = 'templates/import_into_project_from_template_id';
76
+ exports.ENDPOINT_REST_ACCESS_TOKENS_MIGRATE = 'access_tokens/migrate_personal_token';
77
+ exports.ENDPOINT_REST_BACKUPS = 'backups';
78
+ exports.ENDPOINT_REST_BACKUPS_DOWNLOAD = 'backups/download';
79
+ exports.ENDPOINT_REST_EMAILS = 'emails';
80
+ exports.ENDPOINT_REST_ID_MAPPINGS = 'id_mappings';
81
+ exports.ENDPOINT_REST_MOVED_IDS = 'moved_ids';
82
+ exports.ENDPOINT_SYNC_QUICK_ADD = exports.ENDPOINT_REST_TASKS + '/quick';
83
+ exports.ENDPOINT_SYNC = 'sync';
84
+ exports.ENDPOINT_AUTHORIZATION = 'authorize';
85
+ exports.ENDPOINT_GET_TOKEN = 'access_token';
86
+ exports.ENDPOINT_REVOKE = 'revoke';
87
+ exports.ENDPOINT_REST_FOLDERS = 'folders';
88
+ // Workspace endpoints
89
+ exports.ENDPOINT_REST_WORKSPACES = 'workspaces';
90
+ exports.ENDPOINT_WORKSPACE_INVITATIONS = 'workspaces/invitations';
91
+ exports.ENDPOINT_WORKSPACE_INVITATIONS_ALL = 'workspaces/invitations/all';
92
+ exports.ENDPOINT_WORKSPACE_INVITATIONS_DELETE = 'workspaces/invitations/delete';
93
+ exports.ENDPOINT_WORKSPACE_JOIN = 'workspaces/join';
94
+ exports.ENDPOINT_WORKSPACE_LOGO = 'workspaces/logo';
95
+ exports.ENDPOINT_WORKSPACE_PLAN_DETAILS = 'workspaces/plan_details';
96
+ exports.ENDPOINT_WORKSPACE_USERS = 'workspaces/users';
97
+ // Workspace invitation actions (require invite_code parameter)
98
+ function getWorkspaceInvitationAcceptEndpoint(inviteCode) {
99
+ return `workspaces/invitations/${inviteCode}/accept`;
100
+ }
101
+ function getWorkspaceInvitationRejectEndpoint(inviteCode) {
102
+ return `workspaces/invitations/${inviteCode}/reject`;
103
+ }
104
+ // Insights endpoints
105
+ function getProjectInsightsActivityStatsEndpoint(projectId) {
106
+ return `projects/${projectId}/insights/activity_stats`;
107
+ }
108
+ function getProjectInsightsHealthEndpoint(projectId) {
109
+ return `projects/${projectId}/insights/health`;
110
+ }
111
+ function getProjectInsightsHealthContextEndpoint(projectId) {
112
+ return `projects/${projectId}/insights/health/context`;
113
+ }
114
+ function getProjectInsightsProgressEndpoint(projectId) {
115
+ return `projects/${projectId}/insights/progress`;
116
+ }
117
+ function getProjectInsightsHealthAnalyzeEndpoint(projectId) {
118
+ return `projects/${projectId}/insights/health/analyze`;
119
+ }
120
+ function getWorkspaceInsightsEndpoint(workspaceId) {
121
+ return `workspaces/${workspaceId}/insights`;
122
+ }
123
+ // Workspace members
124
+ exports.ENDPOINT_WORKSPACE_MEMBERS = 'workspaces/members';
125
+ // Workspace user management (require workspace_id and/or user_id parameters)
126
+ function getWorkspaceUserTasksEndpoint(workspaceId, userId) {
127
+ return `workspaces/${workspaceId}/users/${userId}/tasks`;
128
+ }
129
+ function getWorkspaceInviteUsersEndpoint(workspaceId) {
130
+ return `workspaces/${workspaceId}/users/invite`;
131
+ }
132
+ function getWorkspaceUserEndpoint(workspaceId, userId) {
133
+ return `workspaces/${workspaceId}/users/${userId}`;
134
+ }
135
+ // Workspace projects (require workspace_id parameter)
136
+ function getWorkspaceActiveProjectsEndpoint(workspaceId) {
137
+ return `workspaces/${workspaceId}/projects/active`;
138
+ }
139
+ function getWorkspaceArchivedProjectsEndpoint(workspaceId) {
140
+ return `workspaces/${workspaceId}/projects/archived`;
141
+ }
@@ -0,0 +1,20 @@
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("./todoist-api"), exports);
18
+ __exportStar(require("./authentication"), exports);
19
+ __exportStar(require("./types"), exports);
20
+ __exportStar(require("./utils"), exports);
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assertInstance = assertInstance;
4
+ // Has to use 'any' to express constructor type
5
+ // oxlint-disable-next-line no-explicit-any
6
+ function assertInstance(value, type) {
7
+ if (value instanceof type) {
8
+ return;
9
+ }
10
+ throw new TypeError(`Unexpected type ${typeof value}`);
11
+ }