@doist/todoist-api-typescript 7.9.1 → 7.10.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 (343) hide show
  1. package/README.md +5 -204
  2. package/index.d.ts +1 -0
  3. package/index.js +1 -0
  4. package/index.mjs +1 -0
  5. package/package.json +12 -92
  6. package/LICENSE +0 -21
  7. package/dist/cjs/authentication.js +0 -204
  8. package/dist/cjs/consts/endpoints.js +0 -141
  9. package/dist/cjs/index.js +0 -20
  10. package/dist/cjs/package.json +0 -1
  11. package/dist/cjs/test-utils/asserts.js +0 -11
  12. package/dist/cjs/test-utils/msw-setup.js +0 -97
  13. package/dist/cjs/test-utils/obsidian-fetch-adapter.js +0 -53
  14. package/dist/cjs/test-utils/test-defaults.js +0 -240
  15. package/dist/cjs/todoist-api.js +0 -2623
  16. package/dist/cjs/transport/fetch-with-retry.js +0 -206
  17. package/dist/cjs/transport/http-client.js +0 -133
  18. package/dist/cjs/transport/http-dispatcher.js +0 -72
  19. package/dist/cjs/types/activity/index.js +0 -18
  20. package/dist/cjs/types/activity/requests.js +0 -2
  21. package/dist/cjs/types/activity/types.js +0 -28
  22. package/dist/cjs/types/backups/index.js +0 -18
  23. package/dist/cjs/types/backups/requests.js +0 -2
  24. package/dist/cjs/types/backups/types.js +0 -8
  25. package/dist/cjs/types/comments/index.js +0 -18
  26. package/dist/cjs/types/comments/requests.js +0 -2
  27. package/dist/cjs/types/comments/types.js +0 -60
  28. package/dist/cjs/types/common.js +0 -10
  29. package/dist/cjs/types/emails/index.js +0 -17
  30. package/dist/cjs/types/emails/requests.js +0 -5
  31. package/dist/cjs/types/errors.js +0 -29
  32. package/dist/cjs/types/folders/index.js +0 -17
  33. package/dist/cjs/types/folders/requests.js +0 -2
  34. package/dist/cjs/types/http.js +0 -24
  35. package/dist/cjs/types/id-mappings/index.js +0 -18
  36. package/dist/cjs/types/id-mappings/requests.js +0 -20
  37. package/dist/cjs/types/id-mappings/types.js +0 -12
  38. package/dist/cjs/types/index.js +0 -36
  39. package/dist/cjs/types/insights/index.js +0 -18
  40. package/dist/cjs/types/insights/requests.js +0 -2
  41. package/dist/cjs/types/insights/types.js +0 -84
  42. package/dist/cjs/types/labels/index.js +0 -18
  43. package/dist/cjs/types/labels/requests.js +0 -2
  44. package/dist/cjs/types/labels/types.js +0 -11
  45. package/dist/cjs/types/productivity/index.js +0 -17
  46. package/dist/cjs/types/productivity/types.js +0 -67
  47. package/dist/cjs/types/projects/index.js +0 -18
  48. package/dist/cjs/types/projects/requests.js +0 -2
  49. package/dist/cjs/types/projects/types.js +0 -56
  50. package/dist/cjs/types/reminders/index.js +0 -17
  51. package/dist/cjs/types/reminders/requests.js +0 -95
  52. package/dist/cjs/types/sections/index.js +0 -18
  53. package/dist/cjs/types/sections/requests.js +0 -2
  54. package/dist/cjs/types/sections/types.js +0 -22
  55. package/dist/cjs/types/sync/commands/calendars.js +0 -2
  56. package/dist/cjs/types/sync/commands/filters.js +0 -2
  57. package/dist/cjs/types/sync/commands/folders.js +0 -2
  58. package/dist/cjs/types/sync/commands/index.js +0 -35
  59. package/dist/cjs/types/sync/commands/labels.js +0 -5
  60. package/dist/cjs/types/sync/commands/notes.js +0 -2
  61. package/dist/cjs/types/sync/commands/notifications.js +0 -2
  62. package/dist/cjs/types/sync/commands/others.js +0 -2
  63. package/dist/cjs/types/sync/commands/project-view-options.js +0 -2
  64. package/dist/cjs/types/sync/commands/projects.js +0 -2
  65. package/dist/cjs/types/sync/commands/reminders.js +0 -2
  66. package/dist/cjs/types/sync/commands/sections.js +0 -2
  67. package/dist/cjs/types/sync/commands/shared.js +0 -20
  68. package/dist/cjs/types/sync/commands/sharing.js +0 -2
  69. package/dist/cjs/types/sync/commands/tasks.js +0 -2
  70. package/dist/cjs/types/sync/commands/view-options.js +0 -2
  71. package/dist/cjs/types/sync/commands/workspace-filters.js +0 -2
  72. package/dist/cjs/types/sync/commands/workspace-goals.js +0 -2
  73. package/dist/cjs/types/sync/commands/workspaces.js +0 -2
  74. package/dist/cjs/types/sync/index.js +0 -22
  75. package/dist/cjs/types/sync/request.js +0 -2
  76. package/dist/cjs/types/sync/resource-types.js +0 -40
  77. package/dist/cjs/types/sync/resources/calendars.js +0 -31
  78. package/dist/cjs/types/sync/resources/collaborators.js +0 -25
  79. package/dist/cjs/types/sync/resources/completed-info.js +0 -30
  80. package/dist/cjs/types/sync/resources/filters.js +0 -16
  81. package/dist/cjs/types/sync/resources/folders.js +0 -14
  82. package/dist/cjs/types/sync/resources/index.js +0 -33
  83. package/dist/cjs/types/sync/resources/live-notifications.js +0 -39
  84. package/dist/cjs/types/sync/resources/notes.js +0 -23
  85. package/dist/cjs/types/sync/resources/reminders.js +0 -50
  86. package/dist/cjs/types/sync/resources/suggestions.js +0 -42
  87. package/dist/cjs/types/sync/resources/tooltips.js +0 -10
  88. package/dist/cjs/types/sync/resources/user-plan-limits.js +0 -24
  89. package/dist/cjs/types/sync/resources/user-settings.js +0 -42
  90. package/dist/cjs/types/sync/resources/user.js +0 -120
  91. package/dist/cjs/types/sync/resources/view-options.js +0 -83
  92. package/dist/cjs/types/sync/resources/workspace-filters.js +0 -21
  93. package/dist/cjs/types/sync/resources/workspace-goals.js +0 -32
  94. package/dist/cjs/types/sync/resources/workspaces.js +0 -73
  95. package/dist/cjs/types/sync/response.js +0 -2
  96. package/dist/cjs/types/sync/user-preferences.js +0 -71
  97. package/dist/cjs/types/tasks/index.js +0 -18
  98. package/dist/cjs/types/tasks/requests.js +0 -2
  99. package/dist/cjs/types/tasks/types.js +0 -59
  100. package/dist/cjs/types/templates/index.js +0 -17
  101. package/dist/cjs/types/templates/requests.js +0 -2
  102. package/dist/cjs/types/uploads/index.js +0 -17
  103. package/dist/cjs/types/uploads/requests.js +0 -2
  104. package/dist/cjs/types/users/index.js +0 -17
  105. package/dist/cjs/types/users/types.js +0 -51
  106. package/dist/cjs/types/workspaces/index.js +0 -18
  107. package/dist/cjs/types/workspaces/requests.js +0 -2
  108. package/dist/cjs/types/workspaces/types.js +0 -155
  109. package/dist/cjs/utils/activity-helpers.js +0 -58
  110. package/dist/cjs/utils/case-conversion.js +0 -69
  111. package/dist/cjs/utils/colors.js +0 -143
  112. package/dist/cjs/utils/index.js +0 -25
  113. package/dist/cjs/utils/multipart-upload.js +0 -178
  114. package/dist/cjs/utils/processing-helpers.js +0 -18
  115. package/dist/cjs/utils/sanitization.js +0 -116
  116. package/dist/cjs/utils/sync-helpers.js +0 -22
  117. package/dist/cjs/utils/uncompletable-helpers.js +0 -60
  118. package/dist/cjs/utils/url-helpers.js +0 -74
  119. package/dist/cjs/utils/validators.js +0 -141
  120. package/dist/esm/authentication.js +0 -196
  121. package/dist/esm/consts/endpoints.js +0 -122
  122. package/dist/esm/index.js +0 -4
  123. package/dist/esm/test-utils/asserts.js +0 -8
  124. package/dist/esm/test-utils/msw-setup.js +0 -88
  125. package/dist/esm/test-utils/obsidian-fetch-adapter.js +0 -50
  126. package/dist/esm/test-utils/test-defaults.js +0 -237
  127. package/dist/esm/todoist-api.js +0 -2619
  128. package/dist/esm/transport/fetch-with-retry.js +0 -203
  129. package/dist/esm/transport/http-client.js +0 -128
  130. package/dist/esm/transport/http-dispatcher.js +0 -35
  131. package/dist/esm/types/activity/index.js +0 -2
  132. package/dist/esm/types/activity/requests.js +0 -1
  133. package/dist/esm/types/activity/types.js +0 -25
  134. package/dist/esm/types/backups/index.js +0 -2
  135. package/dist/esm/types/backups/requests.js +0 -1
  136. package/dist/esm/types/backups/types.js +0 -5
  137. package/dist/esm/types/comments/index.js +0 -2
  138. package/dist/esm/types/comments/requests.js +0 -1
  139. package/dist/esm/types/comments/types.js +0 -57
  140. package/dist/esm/types/common.js +0 -7
  141. package/dist/esm/types/emails/index.js +0 -1
  142. package/dist/esm/types/emails/requests.js +0 -2
  143. package/dist/esm/types/errors.js +0 -24
  144. package/dist/esm/types/folders/index.js +0 -1
  145. package/dist/esm/types/folders/requests.js +0 -1
  146. package/dist/esm/types/http.js +0 -20
  147. package/dist/esm/types/id-mappings/index.js +0 -2
  148. package/dist/esm/types/id-mappings/requests.js +0 -17
  149. package/dist/esm/types/id-mappings/types.js +0 -9
  150. package/dist/esm/types/index.js +0 -20
  151. package/dist/esm/types/insights/index.js +0 -2
  152. package/dist/esm/types/insights/requests.js +0 -1
  153. package/dist/esm/types/insights/types.js +0 -81
  154. package/dist/esm/types/labels/index.js +0 -2
  155. package/dist/esm/types/labels/requests.js +0 -1
  156. package/dist/esm/types/labels/types.js +0 -8
  157. package/dist/esm/types/productivity/index.js +0 -1
  158. package/dist/esm/types/productivity/types.js +0 -64
  159. package/dist/esm/types/projects/index.js +0 -2
  160. package/dist/esm/types/projects/requests.js +0 -1
  161. package/dist/esm/types/projects/types.js +0 -53
  162. package/dist/esm/types/reminders/index.js +0 -1
  163. package/dist/esm/types/reminders/requests.js +0 -92
  164. package/dist/esm/types/sections/index.js +0 -2
  165. package/dist/esm/types/sections/requests.js +0 -1
  166. package/dist/esm/types/sections/types.js +0 -19
  167. package/dist/esm/types/sync/commands/calendars.js +0 -1
  168. package/dist/esm/types/sync/commands/filters.js +0 -1
  169. package/dist/esm/types/sync/commands/folders.js +0 -1
  170. package/dist/esm/types/sync/commands/index.js +0 -19
  171. package/dist/esm/types/sync/commands/labels.js +0 -2
  172. package/dist/esm/types/sync/commands/notes.js +0 -1
  173. package/dist/esm/types/sync/commands/notifications.js +0 -1
  174. package/dist/esm/types/sync/commands/others.js +0 -1
  175. package/dist/esm/types/sync/commands/project-view-options.js +0 -1
  176. package/dist/esm/types/sync/commands/projects.js +0 -1
  177. package/dist/esm/types/sync/commands/reminders.js +0 -1
  178. package/dist/esm/types/sync/commands/sections.js +0 -1
  179. package/dist/esm/types/sync/commands/shared.js +0 -16
  180. package/dist/esm/types/sync/commands/sharing.js +0 -1
  181. package/dist/esm/types/sync/commands/tasks.js +0 -1
  182. package/dist/esm/types/sync/commands/view-options.js +0 -1
  183. package/dist/esm/types/sync/commands/workspace-filters.js +0 -1
  184. package/dist/esm/types/sync/commands/workspace-goals.js +0 -1
  185. package/dist/esm/types/sync/commands/workspaces.js +0 -1
  186. package/dist/esm/types/sync/index.js +0 -6
  187. package/dist/esm/types/sync/request.js +0 -1
  188. package/dist/esm/types/sync/resource-types.js +0 -37
  189. package/dist/esm/types/sync/resources/calendars.js +0 -28
  190. package/dist/esm/types/sync/resources/collaborators.js +0 -22
  191. package/dist/esm/types/sync/resources/completed-info.js +0 -27
  192. package/dist/esm/types/sync/resources/filters.js +0 -13
  193. package/dist/esm/types/sync/resources/folders.js +0 -11
  194. package/dist/esm/types/sync/resources/index.js +0 -17
  195. package/dist/esm/types/sync/resources/live-notifications.js +0 -36
  196. package/dist/esm/types/sync/resources/notes.js +0 -20
  197. package/dist/esm/types/sync/resources/reminders.js +0 -47
  198. package/dist/esm/types/sync/resources/suggestions.js +0 -39
  199. package/dist/esm/types/sync/resources/tooltips.js +0 -7
  200. package/dist/esm/types/sync/resources/user-plan-limits.js +0 -21
  201. package/dist/esm/types/sync/resources/user-settings.js +0 -39
  202. package/dist/esm/types/sync/resources/user.js +0 -117
  203. package/dist/esm/types/sync/resources/view-options.js +0 -80
  204. package/dist/esm/types/sync/resources/workspace-filters.js +0 -18
  205. package/dist/esm/types/sync/resources/workspace-goals.js +0 -29
  206. package/dist/esm/types/sync/resources/workspaces.js +0 -70
  207. package/dist/esm/types/sync/response.js +0 -1
  208. package/dist/esm/types/sync/user-preferences.js +0 -68
  209. package/dist/esm/types/tasks/index.js +0 -2
  210. package/dist/esm/types/tasks/requests.js +0 -1
  211. package/dist/esm/types/tasks/types.js +0 -56
  212. package/dist/esm/types/templates/index.js +0 -1
  213. package/dist/esm/types/templates/requests.js +0 -1
  214. package/dist/esm/types/uploads/index.js +0 -1
  215. package/dist/esm/types/uploads/requests.js +0 -1
  216. package/dist/esm/types/users/index.js +0 -1
  217. package/dist/esm/types/users/types.js +0 -48
  218. package/dist/esm/types/workspaces/index.js +0 -2
  219. package/dist/esm/types/workspaces/requests.js +0 -1
  220. package/dist/esm/types/workspaces/types.js +0 -152
  221. package/dist/esm/utils/activity-helpers.js +0 -53
  222. package/dist/esm/utils/case-conversion.js +0 -61
  223. package/dist/esm/utils/colors.js +0 -139
  224. package/dist/esm/utils/index.js +0 -4
  225. package/dist/esm/utils/multipart-upload.js +0 -142
  226. package/dist/esm/utils/processing-helpers.js +0 -12
  227. package/dist/esm/utils/sanitization.js +0 -112
  228. package/dist/esm/utils/sync-helpers.js +0 -19
  229. package/dist/esm/utils/uncompletable-helpers.js +0 -54
  230. package/dist/esm/utils/url-helpers.js +0 -68
  231. package/dist/esm/utils/validators.js +0 -132
  232. package/dist/types/authentication.d.ts +0 -158
  233. package/dist/types/consts/endpoints.d.ts +0 -81
  234. package/dist/types/index.d.ts +0 -4
  235. package/dist/types/test-utils/asserts.d.ts +0 -1
  236. package/dist/types/test-utils/msw-setup.d.ts +0 -33
  237. package/dist/types/test-utils/obsidian-fetch-adapter.d.ts +0 -29
  238. package/dist/types/test-utils/test-defaults.d.ts +0 -261
  239. package/dist/types/todoist-api.d.ts +0 -1018
  240. package/dist/types/transport/fetch-with-retry.d.ts +0 -12
  241. package/dist/types/transport/http-client.d.ts +0 -16
  242. package/dist/types/transport/http-dispatcher.d.ts +0 -3
  243. package/dist/types/types/activity/index.d.ts +0 -2
  244. package/dist/types/types/activity/requests.d.ts +0 -85
  245. package/dist/types/types/activity/types.d.ts +0 -49
  246. package/dist/types/types/backups/index.d.ts +0 -2
  247. package/dist/types/types/backups/requests.d.ts +0 -16
  248. package/dist/types/types/backups/types.d.ts +0 -7
  249. package/dist/types/types/comments/index.d.ts +0 -2
  250. package/dist/types/types/comments/requests.d.ts +0 -64
  251. package/dist/types/types/comments/types.d.ts +0 -141
  252. package/dist/types/types/common.d.ts +0 -13
  253. package/dist/types/types/emails/index.d.ts +0 -1
  254. package/dist/types/types/emails/requests.d.ts +0 -30
  255. package/dist/types/types/errors.d.ts +0 -12
  256. package/dist/types/types/folders/index.d.ts +0 -1
  257. package/dist/types/types/folders/requests.d.ts +0 -20
  258. package/dist/types/types/http.d.ts +0 -85
  259. package/dist/types/types/id-mappings/index.d.ts +0 -2
  260. package/dist/types/types/id-mappings/requests.d.ts +0 -28
  261. package/dist/types/types/id-mappings/types.d.ts +0 -13
  262. package/dist/types/types/index.d.ts +0 -20
  263. package/dist/types/types/insights/index.d.ts +0 -2
  264. package/dist/types/types/insights/requests.d.ts +0 -26
  265. package/dist/types/types/insights/types.d.ts +0 -186
  266. package/dist/types/types/labels/index.d.ts +0 -2
  267. package/dist/types/types/labels/requests.d.ts +0 -75
  268. package/dist/types/types/labels/types.d.ts +0 -13
  269. package/dist/types/types/productivity/index.d.ts +0 -1
  270. package/dist/types/types/productivity/types.d.ts +0 -115
  271. package/dist/types/types/projects/index.d.ts +0 -2
  272. package/dist/types/types/projects/requests.d.ts +0 -169
  273. package/dist/types/types/projects/types.d.ts +0 -201
  274. package/dist/types/types/reminders/index.d.ts +0 -1
  275. package/dist/types/types/reminders/requests.d.ts +0 -205
  276. package/dist/types/types/sections/index.d.ts +0 -2
  277. package/dist/types/types/sections/requests.d.ts +0 -41
  278. package/dist/types/types/sections/types.d.ts +0 -44
  279. package/dist/types/types/sync/commands/calendars.d.ts +0 -14
  280. package/dist/types/types/sync/commands/filters.d.ts +0 -22
  281. package/dist/types/types/sync/commands/folders.d.ts +0 -18
  282. package/dist/types/types/sync/commands/index.d.ts +0 -171
  283. package/dist/types/types/sync/commands/labels.d.ts +0 -32
  284. package/dist/types/types/sync/commands/notes.d.ts +0 -27
  285. package/dist/types/types/sync/commands/notifications.d.ts +0 -10
  286. package/dist/types/types/sync/commands/others.d.ts +0 -39
  287. package/dist/types/types/sync/commands/project-view-options.d.ts +0 -14
  288. package/dist/types/types/sync/commands/projects.d.ts +0 -90
  289. package/dist/types/types/sync/commands/reminders.d.ts +0 -51
  290. package/dist/types/types/sync/commands/sections.d.ts +0 -31
  291. package/dist/types/types/sync/commands/shared.d.ts +0 -51
  292. package/dist/types/types/sync/commands/sharing.d.ts +0 -16
  293. package/dist/types/types/sync/commands/tasks.d.ts +0 -78
  294. package/dist/types/types/sync/commands/view-options.d.ts +0 -15
  295. package/dist/types/types/sync/commands/workspace-filters.d.ts +0 -23
  296. package/dist/types/types/sync/commands/workspace-goals.d.ts +0 -24
  297. package/dist/types/types/sync/commands/workspaces.d.ts +0 -79
  298. package/dist/types/types/sync/index.d.ts +0 -6
  299. package/dist/types/types/sync/request.d.ts +0 -7
  300. package/dist/types/types/sync/resource-types.d.ts +0 -5
  301. package/dist/types/types/sync/resources/calendars.d.ts +0 -38
  302. package/dist/types/types/sync/resources/collaborators.d.ts +0 -28
  303. package/dist/types/types/sync/resources/completed-info.d.ts +0 -33
  304. package/dist/types/types/sync/resources/filters.d.ts +0 -12
  305. package/dist/types/types/sync/resources/folders.d.ts +0 -10
  306. package/dist/types/types/sync/resources/index.d.ts +0 -17
  307. package/dist/types/types/sync/resources/live-notifications.d.ts +0 -32
  308. package/dist/types/types/sync/resources/notes.d.ts +0 -34
  309. package/dist/types/types/sync/resources/reminders.d.ts +0 -126
  310. package/dist/types/types/sync/resources/suggestions.d.ts +0 -96
  311. package/dist/types/types/sync/resources/tooltips.d.ts +0 -6
  312. package/dist/types/types/sync/resources/user-plan-limits.d.ts +0 -41
  313. package/dist/types/types/sync/resources/user-settings.d.ts +0 -40
  314. package/dist/types/types/sync/resources/user.d.ts +0 -134
  315. package/dist/types/types/sync/resources/view-options.d.ts +0 -169
  316. package/dist/types/types/sync/resources/workspace-filters.d.ts +0 -17
  317. package/dist/types/types/sync/resources/workspace-goals.d.ts +0 -29
  318. package/dist/types/types/sync/resources/workspaces.d.ts +0 -142
  319. package/dist/types/types/sync/response.d.ts +0 -51
  320. package/dist/types/types/sync/user-preferences.d.ts +0 -39
  321. package/dist/types/types/tasks/index.d.ts +0 -2
  322. package/dist/types/types/tasks/requests.d.ts +0 -197
  323. package/dist/types/types/tasks/types.d.ts +0 -162
  324. package/dist/types/types/templates/index.d.ts +0 -1
  325. package/dist/types/types/templates/requests.d.ts +0 -92
  326. package/dist/types/types/uploads/index.d.ts +0 -1
  327. package/dist/types/types/uploads/requests.d.ts +0 -32
  328. package/dist/types/types/users/index.d.ts +0 -1
  329. package/dist/types/types/users/types.d.ts +0 -66
  330. package/dist/types/types/workspaces/index.d.ts +0 -2
  331. package/dist/types/types/workspaces/requests.d.ts +0 -260
  332. package/dist/types/types/workspaces/types.d.ts +0 -267
  333. package/dist/types/utils/activity-helpers.d.ts +0 -28
  334. package/dist/types/utils/case-conversion.d.ts +0 -12
  335. package/dist/types/utils/colors.d.ts +0 -197
  336. package/dist/types/utils/index.d.ts +0 -4
  337. package/dist/types/utils/multipart-upload.d.ts +0 -54
  338. package/dist/types/utils/processing-helpers.d.ts +0 -1
  339. package/dist/types/utils/sanitization.d.ts +0 -35
  340. package/dist/types/utils/sync-helpers.d.ts +0 -17
  341. package/dist/types/utils/uncompletable-helpers.d.ts +0 -30
  342. package/dist/types/utils/url-helpers.d.ts +0 -32
  343. package/dist/types/utils/validators.d.ts +0 -1404
@@ -1,203 +0,0 @@
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 { isNetworkError } from '../types/http.js';
13
- import { getDefaultDispatcher } from './http-dispatcher.js';
14
- /**
15
- * Default retry configuration matching the original axios-retry behavior
16
- */
17
- const DEFAULT_RETRY_CONFIG = {
18
- retries: 3,
19
- retryCondition: isNetworkError,
20
- retryDelay: (retryNumber) => {
21
- // First retry: immediate (0ms delay)
22
- // Subsequent retries: 500ms delay
23
- return retryNumber === 1 ? 0 : 500;
24
- },
25
- };
26
- const TIMEOUT_ERROR_NAME = 'TimeoutError';
27
- function createTimeoutError(timeoutMs) {
28
- const error = new Error(`Request timeout after ${timeoutMs}ms`);
29
- error.name = TIMEOUT_ERROR_NAME;
30
- return error;
31
- }
32
- /**
33
- * Converts Headers object to a plain object
34
- */
35
- function headersToObject(headers) {
36
- const result = {};
37
- headers.forEach((value, key) => {
38
- result[key] = value;
39
- });
40
- return result;
41
- }
42
- /**
43
- * Creates an AbortSignal that aborts after timeoutMs. Returns the signal and a
44
- * clear function to cancel the timeout early.
45
- */
46
- function createTimeoutSignal(timeoutMs, existingSignal) {
47
- const controller = new AbortController();
48
- // Timeout logic
49
- const timeoutId = setTimeout(() => {
50
- controller.abort(createTimeoutError(timeoutMs));
51
- }, timeoutMs);
52
- let abortHandler;
53
- function clear() {
54
- clearTimeout(timeoutId);
55
- if (existingSignal && abortHandler) {
56
- existingSignal.removeEventListener('abort', abortHandler);
57
- }
58
- }
59
- // If there's an existing signal, forward its abort
60
- if (existingSignal) {
61
- if (existingSignal.aborted) {
62
- clearTimeout(timeoutId);
63
- controller.abort(existingSignal.reason);
64
- }
65
- else {
66
- abortHandler = () => {
67
- clearTimeout(timeoutId);
68
- controller.abort(existingSignal.reason);
69
- };
70
- existingSignal.addEventListener('abort', abortHandler, { once: true });
71
- }
72
- }
73
- // Clean up timeout when request completes
74
- controller.signal.addEventListener('abort', () => {
75
- clearTimeout(timeoutId);
76
- });
77
- return { signal: controller.signal, clear };
78
- }
79
- /**
80
- * Converts native fetch Response to CustomFetchResponse for consistency
81
- */
82
- function convertResponseToCustomFetch(response) {
83
- // Clone the response so we can read it multiple times (if clone method exists)
84
- const clonedResponse = response.clone ? response.clone() : response;
85
- return {
86
- ok: response.ok,
87
- status: response.status,
88
- statusText: response.statusText,
89
- headers: headersToObject(response.headers),
90
- text: () => clonedResponse.text(),
91
- json: () => response.json(),
92
- };
93
- }
94
- /**
95
- * Performs a fetch request with retry logic and timeout support
96
- */
97
- export async function fetchWithRetry(args) {
98
- const { url, options = {}, retryConfig = {}, customFetch } = args;
99
- const config = Object.assign(Object.assign({}, DEFAULT_RETRY_CONFIG), retryConfig);
100
- const { timeout, signal: userSignal } = options, fetchOptions = __rest(options, ["timeout", "signal"]);
101
- let lastError;
102
- for (let attempt = 0; attempt <= config.retries; attempt++) {
103
- // Timeout clear function for this attempt (hoisted for catch scope)
104
- let clearTimeoutFn;
105
- try {
106
- // Set up timeout and signal handling
107
- let requestSignal = userSignal || undefined;
108
- if (timeout && timeout > 0) {
109
- const timeoutResult = createTimeoutSignal(timeout, requestSignal);
110
- requestSignal = timeoutResult.signal;
111
- clearTimeoutFn = timeoutResult.clear;
112
- }
113
- // Use custom fetch or native fetch
114
- let fetchResponse;
115
- if (customFetch) {
116
- fetchResponse = await customFetch(url, Object.assign(Object.assign({}, fetchOptions), { signal: requestSignal, timeout }));
117
- }
118
- else {
119
- const dispatcher = await getDefaultDispatcher();
120
- const nativeFetchOptions = Object.assign(Object.assign({}, fetchOptions), { signal: requestSignal });
121
- if (dispatcher !== undefined) {
122
- // @ts-expect-error - dispatcher is a valid option for Node.js fetch but not in the TS types
123
- nativeFetchOptions.dispatcher = dispatcher;
124
- }
125
- const nativeResponse = await fetch(url, nativeFetchOptions);
126
- fetchResponse = convertResponseToCustomFetch(nativeResponse);
127
- }
128
- // Check if the response is successful
129
- if (!fetchResponse.ok) {
130
- const errorMessage = `HTTP ${fetchResponse.status}: ${fetchResponse.statusText}`;
131
- const error = new Error(errorMessage);
132
- error.status = fetchResponse.status;
133
- error.statusText = fetchResponse.statusText;
134
- error.response = {
135
- data: undefined, // Will be set below if we can parse the response
136
- status: fetchResponse.status,
137
- statusText: fetchResponse.statusText,
138
- headers: fetchResponse.headers,
139
- };
140
- // Try to get response body for error details
141
- try {
142
- const responseText = await fetchResponse.text();
143
- let responseData;
144
- try {
145
- responseData = responseText ? JSON.parse(responseText) : undefined;
146
- }
147
- catch (_a) {
148
- responseData = responseText;
149
- }
150
- error.data = responseData;
151
- error.response.data = responseData;
152
- }
153
- catch (_b) {
154
- // If we can't read the response body, that's OK
155
- }
156
- throw error;
157
- }
158
- // Parse response
159
- const responseText = await fetchResponse.text();
160
- let data;
161
- try {
162
- data = responseText ? JSON.parse(responseText) : undefined;
163
- }
164
- catch (_c) {
165
- // If JSON parsing fails, return the raw text
166
- data = responseText;
167
- }
168
- // Success – clear pending timeout (if any) so Node can exit promptly
169
- if (clearTimeoutFn) {
170
- clearTimeoutFn();
171
- }
172
- return {
173
- data,
174
- status: fetchResponse.status,
175
- statusText: fetchResponse.statusText,
176
- headers: fetchResponse.headers,
177
- };
178
- }
179
- catch (error) {
180
- if (clearTimeoutFn) {
181
- clearTimeoutFn();
182
- }
183
- lastError = error;
184
- // Check if this error should trigger a retry
185
- const shouldRetry = attempt < config.retries && config.retryCondition(lastError);
186
- if (!shouldRetry) {
187
- // Add network error flag for network errors
188
- if (isNetworkError(lastError)) {
189
- const networkError = lastError;
190
- networkError.isNetworkError = true;
191
- }
192
- throw lastError;
193
- }
194
- // Wait before retrying
195
- const delay = config.retryDelay(attempt + 1);
196
- if (delay > 0) {
197
- await new Promise((resolve) => setTimeout(resolve, delay));
198
- }
199
- }
200
- }
201
- // This should never be reached, but just in case
202
- throw lastError || new Error('Request failed after retries');
203
- }
@@ -1,128 +0,0 @@
1
- import { v4 as uuidv4 } from 'uuid';
2
- import { API_BASE_URI } from '../consts/endpoints.js';
3
- import { TodoistRequestError } from '../types/errors.js';
4
- import { isHttpError, isNetworkError } from '../types/http.js';
5
- import { camelCaseKeys, snakeCaseKeys } from '../utils/case-conversion.js';
6
- import { fetchWithRetry } from './fetch-with-retry.js';
7
- export function paramsSerializer(params) {
8
- const qs = new URLSearchParams();
9
- Object.keys(params).forEach((key) => {
10
- const value = params[key];
11
- if (value !== null && value !== undefined) {
12
- if (Array.isArray(value)) {
13
- qs.append(key, JSON.stringify(value));
14
- }
15
- else if (typeof value === 'string' ||
16
- typeof value === 'number' ||
17
- typeof value === 'boolean') {
18
- qs.append(key, String(value));
19
- }
20
- else {
21
- qs.append(key, JSON.stringify(value));
22
- }
23
- }
24
- });
25
- return qs.toString();
26
- }
27
- const defaultHeaders = {
28
- 'Content-Type': 'application/json',
29
- };
30
- function getAuthHeader(apiKey) {
31
- return `Bearer ${apiKey}`;
32
- }
33
- function getRetryDelay(retryCount) {
34
- return retryCount === 1 ? 0 : 500;
35
- }
36
- function getTodoistRequestError(args) {
37
- const { error, originalStack } = args;
38
- const requestError = new TodoistRequestError(error.message);
39
- requestError.stack = originalStack ? originalStack.stack : error.stack;
40
- if (isHttpError(error)) {
41
- requestError.httpStatusCode = error.status;
42
- requestError.responseData = error.data;
43
- }
44
- return requestError;
45
- }
46
- function getRequestConfiguration(args) {
47
- const { baseURL, apiToken, requestId, customHeaders } = args;
48
- const authHeader = apiToken ? { Authorization: getAuthHeader(apiToken) } : undefined;
49
- const requestIdHeader = requestId ? { 'X-Request-Id': requestId } : undefined;
50
- const headers = Object.assign(Object.assign(Object.assign(Object.assign({}, defaultHeaders), authHeader), requestIdHeader), customHeaders);
51
- return { baseURL, headers };
52
- }
53
- function getHttpClientConfig(args) {
54
- const { baseURL, apiToken, requestId, customHeaders } = args;
55
- const configuration = getRequestConfiguration({ baseURL, apiToken, requestId, customHeaders });
56
- return Object.assign(Object.assign({}, configuration), { timeout: 30000, retry: {
57
- retries: 3,
58
- retryCondition: isNetworkError,
59
- retryDelay: getRetryDelay,
60
- } });
61
- }
62
- export function isSuccess(response) {
63
- return response.status >= 200 && response.status < 300;
64
- }
65
- export async function request(args) {
66
- const { httpMethod, baseUri, relativePath, apiToken, payload, requestId: initialRequestId, hasSyncCommands, customHeaders, customFetch, } = args;
67
- // Capture original stack for better error reporting
68
- const originalStack = new Error();
69
- try {
70
- let requestId = initialRequestId;
71
- // Sync api don't allow a request id in the CORS
72
- if (httpMethod === 'POST' && !requestId && !baseUri.includes(API_BASE_URI)) {
73
- requestId = uuidv4();
74
- }
75
- const config = getHttpClientConfig({ baseURL: baseUri, apiToken, requestId, customHeaders });
76
- const url = `${baseUri}${relativePath}`;
77
- const fetchOptions = {
78
- method: httpMethod,
79
- headers: config.headers,
80
- timeout: config.timeout,
81
- };
82
- let finalUrl = url;
83
- switch (httpMethod) {
84
- case 'GET':
85
- // For GET requests, add query parameters to URL
86
- if (payload) {
87
- // Convert payload from camelCase to snake_case
88
- const convertedPayload = snakeCaseKeys(payload);
89
- const queryString = paramsSerializer(convertedPayload);
90
- if (queryString) {
91
- const separator = url.includes('?') ? '&' : '?';
92
- finalUrl = `${url}${separator}${queryString}`;
93
- }
94
- }
95
- break;
96
- case 'POST':
97
- case 'PUT':
98
- case 'DELETE': {
99
- // Convert payload from camelCase to snake_case
100
- // Note: While DELETE with body is uncommon, the Todoist API uses it for some endpoints
101
- if (payload) {
102
- const convertedPayload = snakeCaseKeys(payload);
103
- const body = hasSyncCommands
104
- ? JSON.stringify(convertedPayload)
105
- : JSON.stringify(convertedPayload);
106
- fetchOptions.body = body;
107
- }
108
- break;
109
- }
110
- }
111
- // Make the request
112
- const response = await fetchWithRetry({
113
- url: finalUrl,
114
- options: fetchOptions,
115
- retryConfig: config.retry,
116
- customFetch,
117
- });
118
- // Convert snake_case response to camelCase
119
- const convertedData = camelCaseKeys(response.data);
120
- return Object.assign(Object.assign({}, response), { data: convertedData });
121
- }
122
- catch (error) {
123
- if (!(error instanceof Error)) {
124
- throw new Error('An unknown error occurred during the request');
125
- }
126
- throw getTodoistRequestError({ error, originalStack });
127
- }
128
- }
@@ -1,35 +0,0 @@
1
- // Use effectively-disabled keep-alive so short-lived CLI processes do not stay
2
- // open waiting on idle sockets. Undici requires positive values, so we use 1ms.
3
- const KEEP_ALIVE_OPTIONS = {
4
- keepAliveTimeout: 1,
5
- keepAliveMaxTimeout: 1,
6
- };
7
- let defaultDispatcherPromise;
8
- export function getDefaultDispatcher() {
9
- if (!isNodeEnvironment()) {
10
- return Promise.resolve(undefined);
11
- }
12
- if (!defaultDispatcherPromise) {
13
- defaultDispatcherPromise = createDefaultDispatcher().catch((error) => {
14
- defaultDispatcherPromise = undefined;
15
- throw error;
16
- });
17
- }
18
- return defaultDispatcherPromise;
19
- }
20
- export async function resetDefaultDispatcherForTests() {
21
- if (!defaultDispatcherPromise) {
22
- return;
23
- }
24
- const dispatcherPromise = defaultDispatcherPromise;
25
- defaultDispatcherPromise = undefined;
26
- await dispatcherPromise.then((dispatcher) => dispatcher.close(), () => undefined);
27
- }
28
- async function createDefaultDispatcher() {
29
- const { EnvHttpProxyAgent } = await import('undici');
30
- return new EnvHttpProxyAgent(KEEP_ALIVE_OPTIONS);
31
- }
32
- function isNodeEnvironment() {
33
- var _a;
34
- return typeof process !== 'undefined' && Boolean((_a = process.versions) === null || _a === void 0 ? void 0 : _a.node);
35
- }
@@ -1,2 +0,0 @@
1
- export * from './types.js';
2
- export * from './requests.js';
@@ -1 +0,0 @@
1
- export {};
@@ -1,25 +0,0 @@
1
- import { z } from 'zod';
2
- /**
3
- * Flexible object containing event-specific data.
4
- * Uses z.record to accept any properties for forward compatibility.
5
- */
6
- export const ActivityEventExtraDataSchema = z.record(z.string(), z.any()).nullable();
7
- /**
8
- * Activity log event schema. Accepts unknown fields for forward compatibility.
9
- */
10
- export const ActivityEventSchema = z
11
- .object({
12
- objectType: z.string(),
13
- objectId: z.string(),
14
- eventType: z.string(),
15
- eventDate: z.string(),
16
- id: z
17
- .union([z.string(), z.number()])
18
- .transform((val) => { var _a; return (_a = val === null || val === void 0 ? void 0 : val.toString()) !== null && _a !== void 0 ? _a : null; })
19
- .nullable(),
20
- parentProjectId: z.string().nullable(),
21
- parentItemId: z.string().nullable(),
22
- initiatorId: z.string().nullable(),
23
- extraData: ActivityEventExtraDataSchema,
24
- })
25
- .catchall(z.any());
@@ -1,2 +0,0 @@
1
- export * from './types.js';
2
- export * from './requests.js';
@@ -1 +0,0 @@
1
- export {};
@@ -1,5 +0,0 @@
1
- import { z } from 'zod';
2
- export const BackupSchema = z.object({
3
- version: z.string(),
4
- url: z.string(),
5
- });
@@ -1,2 +0,0 @@
1
- export * from './types.js';
2
- export * from './requests.js';
@@ -1 +0,0 @@
1
- export {};
@@ -1,57 +0,0 @@
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
- /** Available file attachment upload states. */
14
- export const UPLOAD_STATES = ['pending', 'completed'];
15
- export const AttachmentSchema = z
16
- .object({
17
- resourceType: z.string(),
18
- })
19
- .extend({
20
- fileName: z.string().nullable().optional(),
21
- fileSize: z.number().int().nullable().optional(),
22
- fileType: z.string().nullable().optional(),
23
- fileUrl: z.string().nullable().optional(),
24
- fileDuration: z.number().int().nullable().optional(),
25
- uploadState: z.enum(UPLOAD_STATES).nullable().optional(),
26
- image: z.string().nullable().optional(),
27
- imageWidth: z.number().int().nullable().optional(),
28
- imageHeight: z.number().int().nullable().optional(),
29
- url: z.string().nullable().optional(),
30
- title: z.string().nullable().optional(),
31
- });
32
- export const RawCommentSchema = z
33
- .object({
34
- id: z.string(),
35
- itemId: z.string().optional(),
36
- projectId: z.string().optional(),
37
- content: z.string(),
38
- postedAt: z.string(),
39
- fileAttachment: AttachmentSchema.nullable(),
40
- postedUid: z.string(),
41
- uidsToNotify: z.array(z.string()).nullable(),
42
- reactions: z.record(z.string(), z.array(z.string())).nullable(),
43
- isDeleted: z.boolean(),
44
- })
45
- .refine((data) => {
46
- // At least one of itemId or projectId must be present
47
- return ((data.itemId !== undefined && data.projectId === undefined) ||
48
- (data.itemId === undefined && data.projectId !== undefined));
49
- }, {
50
- message: 'Exactly one of itemId or projectId must be provided',
51
- });
52
- export const CommentSchema = RawCommentSchema.transform((data) => {
53
- const { itemId } = data, rest = __rest(data, ["itemId"]);
54
- return Object.assign(Object.assign({}, rest), {
55
- // Map itemId to taskId for backwards compatibility
56
- taskId: itemId });
57
- });
@@ -1,7 +0,0 @@
1
- import { z } from 'zod';
2
- /**
3
- * Zod schema that accepts both string and number values and coerces to string.
4
- * The REST API returns numeric IDs while the Sync API returns string IDs.
5
- */
6
- const StringOrNumberSchema = z.union([z.string(), z.number()]).transform((val) => String(val));
7
- export { StringOrNumberSchema };
@@ -1 +0,0 @@
1
- export * from './requests.js';
@@ -1,2 +0,0 @@
1
- /** Object types that support email forwarding. */
2
- export const EMAIL_OBJECT_TYPES = ['project', 'project_comments', 'task'];
@@ -1,24 +0,0 @@
1
- import { CustomError } from 'ts-custom-error';
2
- const authenticationErrorCodes = [401, 403];
3
- export class TodoistRequestError extends CustomError {
4
- constructor(message, httpStatusCode, responseData) {
5
- super(message);
6
- this.message = message;
7
- this.httpStatusCode = httpStatusCode;
8
- this.responseData = responseData;
9
- this.isAuthenticationError = () => {
10
- if (!this.httpStatusCode) {
11
- return false;
12
- }
13
- return authenticationErrorCodes.includes(this.httpStatusCode);
14
- };
15
- Object.defineProperty(this, 'name', { value: 'TodoistRequestError' });
16
- }
17
- }
18
- export class TodoistArgumentError extends CustomError {
19
- constructor(message) {
20
- super(message);
21
- this.message = message;
22
- Object.defineProperty(this, 'name', { value: 'TodoistArgumentError' });
23
- }
24
- }
@@ -1 +0,0 @@
1
- export * from './requests.js';
@@ -1 +0,0 @@
1
- export {};
@@ -1,20 +0,0 @@
1
- /**
2
- * Type guard to check if an error is a network error
3
- */
4
- export function isNetworkError(error) {
5
- // Network errors in fetch are typically TypeError with specific messages.
6
- // Timeout errors are created by fetch-with-retry with the TimeoutError name.
7
- return ((error instanceof TypeError &&
8
- (error.message.includes('fetch') ||
9
- error.message.includes('network') ||
10
- error.message.includes('Failed to fetch') ||
11
- error.message.includes('NetworkError'))) ||
12
- error.name === 'TimeoutError' ||
13
- error.isNetworkError === true);
14
- }
15
- /**
16
- * Type guard to check if an error is an HTTP error
17
- */
18
- export function isHttpError(error) {
19
- return 'status' in error && typeof error.status === 'number';
20
- }
@@ -1,2 +0,0 @@
1
- export * from './types.js';
2
- export * from './requests.js';
@@ -1,17 +0,0 @@
1
- /** Object types that support ID mappings. */
2
- export const ID_MAPPING_OBJECT_TYPES = [
3
- 'sections',
4
- 'tasks',
5
- 'comments',
6
- 'reminders',
7
- 'location_reminders',
8
- 'projects',
9
- ];
10
- /** Object types that support moved ID lookups. */
11
- export const MOVED_ID_OBJECT_TYPES = [
12
- 'sections',
13
- 'tasks',
14
- 'comments',
15
- 'reminders',
16
- 'location_reminders',
17
- ];
@@ -1,9 +0,0 @@
1
- import { z } from 'zod';
2
- export const IdMappingSchema = z.object({
3
- oldId: z.string().nullable(),
4
- newId: z.string().nullable(),
5
- });
6
- export const MovedIdSchema = z.object({
7
- oldId: z.string(),
8
- newId: z.string(),
9
- });
@@ -1,20 +0,0 @@
1
- export * from './tasks/index.js';
2
- export * from './projects/index.js';
3
- export * from './sections/index.js';
4
- export * from './labels/index.js';
5
- export * from './comments/index.js';
6
- export * from './reminders/index.js';
7
- export * from './users/index.js';
8
- export * from './productivity/index.js';
9
- export * from './activity/index.js';
10
- export * from './workspaces/index.js';
11
- export * from './folders/index.js';
12
- export * from './insights/index.js';
13
- export * from './backups/index.js';
14
- export * from './id-mappings/index.js';
15
- export * from './emails/index.js';
16
- export * from './uploads/index.js';
17
- export * from './templates/index.js';
18
- export * from './errors.js';
19
- export * from './http.js';
20
- export * from './sync/index.js';
@@ -1,2 +0,0 @@
1
- export * from './types.js';
2
- export * from './requests.js';
@@ -1 +0,0 @@
1
- export {};