@todoist/sdk 0.0.0-stage → 18.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (335) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +308 -2
  3. package/dist/esm/authentication.js +307 -0
  4. package/dist/esm/clients/activity-client.js +60 -0
  5. package/dist/esm/clients/app-client.js +366 -0
  6. package/dist/esm/clients/backup-client.js +47 -0
  7. package/dist/esm/clients/base-client.js +29 -0
  8. package/dist/esm/clients/billing-client.js +160 -0
  9. package/dist/esm/clients/comment-client.js +92 -0
  10. package/dist/esm/clients/email-client.js +41 -0
  11. package/dist/esm/clients/filter-client.js +26 -0
  12. package/dist/esm/clients/folder-client.js +80 -0
  13. package/dist/esm/clients/id-mapping-client.js +37 -0
  14. package/dist/esm/clients/insights-client.js +89 -0
  15. package/dist/esm/clients/label-client.js +131 -0
  16. package/dist/esm/clients/productivity-client.js +24 -0
  17. package/dist/esm/clients/project-client.js +284 -0
  18. package/dist/esm/clients/reminder-client.js +204 -0
  19. package/dist/esm/clients/section-client.js +121 -0
  20. package/dist/esm/clients/task-client.js +264 -0
  21. package/dist/esm/clients/template-client.js +89 -0
  22. package/dist/esm/clients/ui-extension-client.js +110 -0
  23. package/dist/esm/clients/upload-client.js +153 -0
  24. package/dist/esm/clients/view-options-client.js +21 -0
  25. package/dist/esm/clients/workspace-client.js +384 -0
  26. package/dist/esm/consts/endpoints.js +193 -0
  27. package/dist/esm/index.js +5 -0
  28. package/dist/esm/test-utils/asserts.js +8 -0
  29. package/dist/esm/test-utils/msw-setup.js +88 -0
  30. package/dist/esm/test-utils/obsidian-fetch-adapter.js +51 -0
  31. package/dist/esm/test-utils/test-defaults.js +367 -0
  32. package/dist/esm/test-utils/transport-seam.js +15 -0
  33. package/dist/esm/test-utils/webhook-fixtures.js +26 -0
  34. package/dist/esm/todoist-api.js +1757 -0
  35. package/dist/esm/transport/fetch-with-retry.js +216 -0
  36. package/dist/esm/transport/http-client.js +140 -0
  37. package/dist/esm/transport/http-dispatcher.js +158 -0
  38. package/dist/esm/transport/sync-request.js +106 -0
  39. package/dist/esm/types/activity/index.js +2 -0
  40. package/dist/esm/types/activity/requests.js +1 -0
  41. package/dist/esm/types/activity/types.js +45 -0
  42. package/dist/esm/types/apps/index.js +2 -0
  43. package/dist/esm/types/apps/requests.js +1 -0
  44. package/dist/esm/types/apps/types.js +249 -0
  45. package/dist/esm/types/backups/index.js +2 -0
  46. package/dist/esm/types/backups/requests.js +1 -0
  47. package/dist/esm/types/backups/types.js +5 -0
  48. package/dist/esm/types/billing/index.js +2 -0
  49. package/dist/esm/types/billing/requests.js +1 -0
  50. package/dist/esm/types/billing/types.js +89 -0
  51. package/dist/esm/types/comments/index.js +2 -0
  52. package/dist/esm/types/comments/requests.js +1 -0
  53. package/dist/esm/types/comments/types.js +57 -0
  54. package/dist/esm/types/common.js +7 -0
  55. package/dist/esm/types/emails/index.js +1 -0
  56. package/dist/esm/types/emails/requests.js +2 -0
  57. package/dist/esm/types/errors.js +41 -0
  58. package/dist/esm/types/folders/index.js +1 -0
  59. package/dist/esm/types/folders/requests.js +1 -0
  60. package/dist/esm/types/http.js +20 -0
  61. package/dist/esm/types/id-mappings/index.js +2 -0
  62. package/dist/esm/types/id-mappings/requests.js +17 -0
  63. package/dist/esm/types/id-mappings/types.js +9 -0
  64. package/dist/esm/types/index.js +24 -0
  65. package/dist/esm/types/insights/index.js +2 -0
  66. package/dist/esm/types/insights/requests.js +1 -0
  67. package/dist/esm/types/insights/types.js +77 -0
  68. package/dist/esm/types/labels/index.js +2 -0
  69. package/dist/esm/types/labels/requests.js +1 -0
  70. package/dist/esm/types/labels/types.js +8 -0
  71. package/dist/esm/types/productivity/index.js +1 -0
  72. package/dist/esm/types/productivity/types.js +65 -0
  73. package/dist/esm/types/projects/index.js +2 -0
  74. package/dist/esm/types/projects/requests.js +1 -0
  75. package/dist/esm/types/projects/types.js +65 -0
  76. package/dist/esm/types/reminders/index.js +1 -0
  77. package/dist/esm/types/reminders/requests.js +92 -0
  78. package/dist/esm/types/sections/index.js +2 -0
  79. package/dist/esm/types/sections/requests.js +1 -0
  80. package/dist/esm/types/sections/types.js +23 -0
  81. package/dist/esm/types/sync/commands/calendars.js +1 -0
  82. package/dist/esm/types/sync/commands/filters.js +1 -0
  83. package/dist/esm/types/sync/commands/folders.js +1 -0
  84. package/dist/esm/types/sync/commands/index.js +18 -0
  85. package/dist/esm/types/sync/commands/labels.js +2 -0
  86. package/dist/esm/types/sync/commands/notes.js +1 -0
  87. package/dist/esm/types/sync/commands/notifications.js +1 -0
  88. package/dist/esm/types/sync/commands/others.js +1 -0
  89. package/dist/esm/types/sync/commands/project-view-options.js +1 -0
  90. package/dist/esm/types/sync/commands/projects.js +1 -0
  91. package/dist/esm/types/sync/commands/reminders.js +1 -0
  92. package/dist/esm/types/sync/commands/sections.js +1 -0
  93. package/dist/esm/types/sync/commands/shared.js +16 -0
  94. package/dist/esm/types/sync/commands/sharing.js +1 -0
  95. package/dist/esm/types/sync/commands/tasks.js +1 -0
  96. package/dist/esm/types/sync/commands/view-options.js +1 -0
  97. package/dist/esm/types/sync/commands/workspace-filters.js +1 -0
  98. package/dist/esm/types/sync/commands/workspaces.js +1 -0
  99. package/dist/esm/types/sync/index.js +6 -0
  100. package/dist/esm/types/sync/request.js +1 -0
  101. package/dist/esm/types/sync/resource-types.js +36 -0
  102. package/dist/esm/types/sync/resources/calendars.js +24 -0
  103. package/dist/esm/types/sync/resources/collaborators.js +21 -0
  104. package/dist/esm/types/sync/resources/completed-info.js +21 -0
  105. package/dist/esm/types/sync/resources/filters.js +12 -0
  106. package/dist/esm/types/sync/resources/folders.js +10 -0
  107. package/dist/esm/types/sync/resources/index.js +18 -0
  108. package/dist/esm/types/sync/resources/labels.js +7 -0
  109. package/dist/esm/types/sync/resources/live-notifications.js +35 -0
  110. package/dist/esm/types/sync/resources/notes.js +18 -0
  111. package/dist/esm/types/sync/resources/reminders.js +58 -0
  112. package/dist/esm/types/sync/resources/suggestions.js +33 -0
  113. package/dist/esm/types/sync/resources/tooltips.js +5 -0
  114. package/dist/esm/types/sync/resources/user-plan-limits.js +21 -0
  115. package/dist/esm/types/sync/resources/user-settings.js +41 -0
  116. package/dist/esm/types/sync/resources/user-status.js +22 -0
  117. package/dist/esm/types/sync/resources/user.js +109 -0
  118. package/dist/esm/types/sync/resources/view-options.js +128 -0
  119. package/dist/esm/types/sync/resources/workspace-filters.js +17 -0
  120. package/dist/esm/types/sync/resources/workspaces.js +69 -0
  121. package/dist/esm/types/sync/response.js +57 -0
  122. package/dist/esm/types/sync/user-preferences.js +68 -0
  123. package/dist/esm/types/tasks/index.js +2 -0
  124. package/dist/esm/types/tasks/requests.js +1 -0
  125. package/dist/esm/types/tasks/types.js +56 -0
  126. package/dist/esm/types/templates/index.js +1 -0
  127. package/dist/esm/types/templates/requests.js +1 -0
  128. package/dist/esm/types/ui-extensions/index.js +2 -0
  129. package/dist/esm/types/ui-extensions/requests.js +1 -0
  130. package/dist/esm/types/ui-extensions/types.js +74 -0
  131. package/dist/esm/types/uploads/index.js +1 -0
  132. package/dist/esm/types/uploads/requests.js +1 -0
  133. package/dist/esm/types/users/index.js +1 -0
  134. package/dist/esm/types/users/types.js +49 -0
  135. package/dist/esm/types/webhooks/comments.js +93 -0
  136. package/dist/esm/types/webhooks/envelope.js +23 -0
  137. package/dist/esm/types/webhooks/filters.js +27 -0
  138. package/dist/esm/types/webhooks/index.js +9 -0
  139. package/dist/esm/types/webhooks/labels.js +51 -0
  140. package/dist/esm/types/webhooks/projects.js +33 -0
  141. package/dist/esm/types/webhooks/reminders.js +32 -0
  142. package/dist/esm/types/webhooks/sections.js +50 -0
  143. package/dist/esm/types/webhooks/tasks.js +65 -0
  144. package/dist/esm/types/webhooks/types.js +52 -0
  145. package/dist/esm/types/workspaces/index.js +2 -0
  146. package/dist/esm/types/workspaces/requests.js +1 -0
  147. package/dist/esm/types/workspaces/types.js +151 -0
  148. package/dist/esm/utils/activity-helpers.js +53 -0
  149. package/dist/esm/utils/case-conversion.js +84 -0
  150. package/dist/esm/utils/colors.js +145 -0
  151. package/dist/esm/utils/file-response.js +29 -0
  152. package/dist/esm/utils/filter-queries.js +231 -0
  153. package/dist/esm/utils/filter-query-definitions.js +2789 -0
  154. package/dist/esm/utils/headers.js +42 -0
  155. package/dist/esm/utils/index.js +11 -0
  156. package/dist/esm/utils/multipart-upload.js +267 -0
  157. package/dist/esm/utils/person-names.js +61 -0
  158. package/dist/esm/utils/processing-helpers.js +12 -0
  159. package/dist/esm/utils/project-helpers.js +29 -0
  160. package/dist/esm/utils/request-helpers.js +43 -0
  161. package/dist/esm/utils/sanitization.js +131 -0
  162. package/dist/esm/utils/sync-helpers.js +19 -0
  163. package/dist/esm/utils/task-sorting.js +280 -0
  164. package/dist/esm/utils/uncompletable-helpers.js +54 -0
  165. package/dist/esm/utils/url-helpers.js +196 -0
  166. package/dist/esm/utils/validators.js +102 -0
  167. package/dist/esm/utils/view-options.js +15 -0
  168. package/dist/esm/utils/webhook-parser.js +56 -0
  169. package/dist/types/authentication.d.ts +262 -0
  170. package/dist/types/clients/activity-client.d.ts +12 -0
  171. package/dist/types/clients/app-client.d.ts +37 -0
  172. package/dist/types/clients/backup-client.d.ts +14 -0
  173. package/dist/types/clients/base-client.d.ts +23 -0
  174. package/dist/types/clients/billing-client.d.ts +22 -0
  175. package/dist/types/clients/comment-client.d.ts +15 -0
  176. package/dist/types/clients/email-client.d.ts +13 -0
  177. package/dist/types/clients/filter-client.d.ts +10 -0
  178. package/dist/types/clients/folder-client.d.ts +16 -0
  179. package/dist/types/clients/id-mapping-client.d.ts +13 -0
  180. package/dist/types/clients/insights-client.d.ts +18 -0
  181. package/dist/types/clients/label-client.d.ts +19 -0
  182. package/dist/types/clients/productivity-client.d.ts +12 -0
  183. package/dist/types/clients/project-client.d.ts +22 -0
  184. package/dist/types/clients/reminder-client.d.ts +25 -0
  185. package/dist/types/clients/section-client.d.ts +18 -0
  186. package/dist/types/clients/task-client.d.ts +25 -0
  187. package/dist/types/clients/template-client.d.ts +17 -0
  188. package/dist/types/clients/ui-extension-client.d.ts +18 -0
  189. package/dist/types/clients/upload-client.d.ts +17 -0
  190. package/dist/types/clients/view-options-client.d.ts +8 -0
  191. package/dist/types/clients/workspace-client.d.ts +43 -0
  192. package/dist/types/consts/endpoints.d.ts +120 -0
  193. package/dist/types/index.d.ts +6 -0
  194. package/dist/types/test-utils/asserts.d.ts +1 -0
  195. package/dist/types/test-utils/msw-setup.d.ts +33 -0
  196. package/dist/types/test-utils/obsidian-fetch-adapter.d.ts +29 -0
  197. package/dist/types/test-utils/test-defaults.d.ts +286 -0
  198. package/dist/types/test-utils/transport-seam.d.ts +1 -0
  199. package/dist/types/test-utils/webhook-fixtures.d.ts +13 -0
  200. package/dist/types/todoist-api.d.ts +1437 -0
  201. package/dist/types/transport/fetch-with-retry.d.ts +12 -0
  202. package/dist/types/transport/http-client.d.ts +25 -0
  203. package/dist/types/transport/http-dispatcher.d.ts +65 -0
  204. package/dist/types/transport/sync-request.d.ts +31 -0
  205. package/dist/types/types/activity/index.d.ts +2 -0
  206. package/dist/types/types/activity/requests.d.ts +85 -0
  207. package/dist/types/types/activity/types.d.ts +56 -0
  208. package/dist/types/types/apps/index.d.ts +2 -0
  209. package/dist/types/types/apps/requests.d.ts +89 -0
  210. package/dist/types/types/apps/types.d.ts +418 -0
  211. package/dist/types/types/backups/index.d.ts +2 -0
  212. package/dist/types/types/backups/requests.d.ts +16 -0
  213. package/dist/types/types/backups/types.d.ts +7 -0
  214. package/dist/types/types/billing/index.d.ts +2 -0
  215. package/dist/types/types/billing/requests.d.ts +62 -0
  216. package/dist/types/types/billing/types.d.ts +207 -0
  217. package/dist/types/types/comments/index.d.ts +2 -0
  218. package/dist/types/types/comments/requests.d.ts +64 -0
  219. package/dist/types/types/comments/types.d.ts +141 -0
  220. package/dist/types/types/common.d.ts +13 -0
  221. package/dist/types/types/emails/index.d.ts +1 -0
  222. package/dist/types/types/emails/requests.d.ts +30 -0
  223. package/dist/types/types/errors.d.ts +29 -0
  224. package/dist/types/types/folders/index.d.ts +1 -0
  225. package/dist/types/types/folders/requests.d.ts +20 -0
  226. package/dist/types/types/http.d.ts +104 -0
  227. package/dist/types/types/id-mappings/index.d.ts +2 -0
  228. package/dist/types/types/id-mappings/requests.d.ts +28 -0
  229. package/dist/types/types/id-mappings/types.d.ts +13 -0
  230. package/dist/types/types/index.d.ts +24 -0
  231. package/dist/types/types/insights/index.d.ts +2 -0
  232. package/dist/types/types/insights/requests.d.ts +26 -0
  233. package/dist/types/types/insights/types.d.ts +167 -0
  234. package/dist/types/types/labels/index.d.ts +2 -0
  235. package/dist/types/types/labels/requests.d.ts +75 -0
  236. package/dist/types/types/labels/types.d.ts +13 -0
  237. package/dist/types/types/productivity/index.d.ts +1 -0
  238. package/dist/types/types/productivity/types.d.ts +115 -0
  239. package/dist/types/types/projects/index.d.ts +2 -0
  240. package/dist/types/types/projects/requests.d.ts +206 -0
  241. package/dist/types/types/projects/types.d.ts +286 -0
  242. package/dist/types/types/reminders/index.d.ts +1 -0
  243. package/dist/types/types/reminders/requests.d.ts +205 -0
  244. package/dist/types/types/sections/index.d.ts +2 -0
  245. package/dist/types/types/sections/requests.d.ts +49 -0
  246. package/dist/types/types/sections/types.d.ts +70 -0
  247. package/dist/types/types/sync/commands/calendars.d.ts +14 -0
  248. package/dist/types/types/sync/commands/filters.d.ts +24 -0
  249. package/dist/types/types/sync/commands/folders.d.ts +20 -0
  250. package/dist/types/types/sync/commands/index.d.ts +167 -0
  251. package/dist/types/types/sync/commands/labels.d.ts +32 -0
  252. package/dist/types/types/sync/commands/notes.d.ts +27 -0
  253. package/dist/types/types/sync/commands/notifications.d.ts +10 -0
  254. package/dist/types/types/sync/commands/others.d.ts +61 -0
  255. package/dist/types/types/sync/commands/project-view-options.d.ts +13 -0
  256. package/dist/types/types/sync/commands/projects.d.ts +96 -0
  257. package/dist/types/types/sync/commands/reminders.d.ts +51 -0
  258. package/dist/types/types/sync/commands/sections.d.ts +36 -0
  259. package/dist/types/types/sync/commands/shared.d.ts +51 -0
  260. package/dist/types/types/sync/commands/sharing.d.ts +16 -0
  261. package/dist/types/types/sync/commands/tasks.d.ts +78 -0
  262. package/dist/types/types/sync/commands/view-options.d.ts +18 -0
  263. package/dist/types/types/sync/commands/workspace-filters.d.ts +25 -0
  264. package/dist/types/types/sync/commands/workspaces.d.ts +82 -0
  265. package/dist/types/types/sync/index.d.ts +6 -0
  266. package/dist/types/types/sync/request.d.ts +7 -0
  267. package/dist/types/types/sync/resource-types.d.ts +5 -0
  268. package/dist/types/types/sync/resources/calendars.d.ts +38 -0
  269. package/dist/types/types/sync/resources/collaborators.d.ts +45 -0
  270. package/dist/types/types/sync/resources/completed-info.d.ts +33 -0
  271. package/dist/types/types/sync/resources/filters.d.ts +13 -0
  272. package/dist/types/types/sync/resources/folders.d.ts +11 -0
  273. package/dist/types/types/sync/resources/index.d.ts +18 -0
  274. package/dist/types/types/sync/resources/labels.d.ts +12 -0
  275. package/dist/types/types/sync/resources/live-notifications.d.ts +32 -0
  276. package/dist/types/types/sync/resources/notes.d.ts +34 -0
  277. package/dist/types/types/sync/resources/reminders.d.ts +213 -0
  278. package/dist/types/types/sync/resources/suggestions.d.ts +96 -0
  279. package/dist/types/types/sync/resources/tooltips.d.ts +6 -0
  280. package/dist/types/types/sync/resources/user-plan-limits.d.ts +47 -0
  281. package/dist/types/types/sync/resources/user-settings.d.ts +40 -0
  282. package/dist/types/types/sync/resources/user-status.d.ts +46 -0
  283. package/dist/types/types/sync/resources/user.d.ts +151 -0
  284. package/dist/types/types/sync/resources/view-options.d.ts +157 -0
  285. package/dist/types/types/sync/resources/workspace-filters.d.ts +18 -0
  286. package/dist/types/types/sync/resources/workspaces.d.ts +142 -0
  287. package/dist/types/types/sync/response.d.ts +930 -0
  288. package/dist/types/types/sync/user-preferences.d.ts +39 -0
  289. package/dist/types/types/tasks/index.d.ts +2 -0
  290. package/dist/types/types/tasks/requests.d.ts +197 -0
  291. package/dist/types/types/tasks/types.d.ts +162 -0
  292. package/dist/types/types/templates/index.d.ts +1 -0
  293. package/dist/types/types/templates/requests.d.ts +92 -0
  294. package/dist/types/types/ui-extensions/index.d.ts +2 -0
  295. package/dist/types/types/ui-extensions/requests.d.ts +108 -0
  296. package/dist/types/types/ui-extensions/types.d.ts +185 -0
  297. package/dist/types/types/uploads/index.d.ts +1 -0
  298. package/dist/types/types/uploads/requests.d.ts +32 -0
  299. package/dist/types/types/users/index.d.ts +1 -0
  300. package/dist/types/types/users/types.d.ts +67 -0
  301. package/dist/types/types/webhooks/comments.d.ts +1600 -0
  302. package/dist/types/types/webhooks/envelope.d.ts +34 -0
  303. package/dist/types/types/webhooks/filters.d.ts +99 -0
  304. package/dist/types/types/webhooks/index.d.ts +9 -0
  305. package/dist/types/types/webhooks/labels.d.ts +160 -0
  306. package/dist/types/types/webhooks/projects.d.ts +365 -0
  307. package/dist/types/types/webhooks/reminders.d.ts +82 -0
  308. package/dist/types/types/webhooks/sections.d.ts +372 -0
  309. package/dist/types/types/webhooks/tasks.d.ts +981 -0
  310. package/dist/types/types/webhooks/types.d.ts +2606 -0
  311. package/dist/types/types/workspaces/index.d.ts +2 -0
  312. package/dist/types/types/workspaces/requests.d.ts +260 -0
  313. package/dist/types/types/workspaces/types.d.ts +266 -0
  314. package/dist/types/utils/activity-helpers.d.ts +28 -0
  315. package/dist/types/utils/case-conversion.d.ts +20 -0
  316. package/dist/types/utils/colors.d.ts +201 -0
  317. package/dist/types/utils/file-response.d.ts +15 -0
  318. package/dist/types/utils/filter-queries.d.ts +42 -0
  319. package/dist/types/utils/filter-query-definitions.d.ts +27 -0
  320. package/dist/types/utils/headers.d.ts +20 -0
  321. package/dist/types/utils/index.d.ts +15 -0
  322. package/dist/types/utils/multipart-upload.d.ts +58 -0
  323. package/dist/types/utils/person-names.d.ts +52 -0
  324. package/dist/types/utils/processing-helpers.d.ts +1 -0
  325. package/dist/types/utils/project-helpers.d.ts +21 -0
  326. package/dist/types/utils/request-helpers.d.ts +33 -0
  327. package/dist/types/utils/sanitization.d.ts +52 -0
  328. package/dist/types/utils/sync-helpers.d.ts +17 -0
  329. package/dist/types/utils/task-sorting.d.ts +46 -0
  330. package/dist/types/utils/uncompletable-helpers.d.ts +30 -0
  331. package/dist/types/utils/url-helpers.d.ts +120 -0
  332. package/dist/types/utils/validators.d.ts +1917 -0
  333. package/dist/types/utils/view-options.d.ts +11 -0
  334. package/dist/types/utils/webhook-parser.d.ts +48 -0
  335. package/package.json +88 -5
@@ -0,0 +1,60 @@
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 { ENDPOINT_REST_ACTIVITIES } from '../consts/endpoints.js';
13
+ import { request } from '../transport/http-client.js';
14
+ import { denormalizeObjectTypeFromApi, normalizeObjectEventTypeForApi, } from '../utils/activity-helpers.js';
15
+ import { formatDateToYYYYMMDD } from '../utils/url-helpers.js';
16
+ import { validateActivityEventArray } from '../utils/validators.js';
17
+ import { BaseClient } from './base-client.js';
18
+ /**
19
+ * Internal sub-client handling the activity-log endpoint.
20
+ *
21
+ * Instantiated by `TodoistApi`; the public `getActivityLogs` method on
22
+ * `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
23
+ * JSDoc.
24
+ */
25
+ export class ActivityClient extends BaseClient {
26
+ async getActivityLogs(args = {}) {
27
+ // Convert Date objects to YYYY-MM-DD strings
28
+ const dateFrom = args.dateFrom instanceof Date ? formatDateToYYYYMMDD(args.dateFrom) : args.dateFrom;
29
+ const dateTo = args.dateTo instanceof Date ? formatDateToYYYYMMDD(args.dateTo) : args.dateTo;
30
+ // Destructure out raw date, filter-type, and removed legacy fields so they don't leak into payload
31
+ const _a = args, { dateFrom: _dateFrom, dateTo: _dateTo, objectEventTypes, objectType: _objectType, eventType: _eventType, since: _since, until: _until } = _a, rest = __rest(_a, ["dateFrom", "dateTo", "objectEventTypes", "objectType", "eventType", "since", "until"]);
32
+ // Build normalized objectEventTypes for the API
33
+ let normalizedObjectEventTypes;
34
+ if (objectEventTypes !== undefined) {
35
+ const arr = Array.isArray(objectEventTypes) ? objectEventTypes : [objectEventTypes];
36
+ normalizedObjectEventTypes = arr.map(normalizeObjectEventTypeForApi);
37
+ }
38
+ const processedArgs = Object.assign(Object.assign(Object.assign(Object.assign({}, rest), (dateFrom !== undefined ? { dateFrom } : {})), (dateTo !== undefined ? { dateTo } : {})), (normalizedObjectEventTypes !== undefined
39
+ ? { objectEventTypes: normalizedObjectEventTypes }
40
+ : {}));
41
+ const { data: { results, nextCursor }, } = await request({
42
+ httpMethod: 'GET',
43
+ baseUri: this.syncApiBase,
44
+ relativePath: ENDPOINT_REST_ACTIVITIES,
45
+ apiToken: this.authToken,
46
+ customFetch: this.customFetch,
47
+ customHeaders: this.customHeaders,
48
+ payload: processedArgs,
49
+ });
50
+ // Convert legacy API object types back to modern SDK types
51
+ const normalizedResults = results.map((event) => {
52
+ const normalizedType = denormalizeObjectTypeFromApi(event.objectType);
53
+ return Object.assign(Object.assign({}, event), { objectType: normalizedType || event.objectType });
54
+ });
55
+ return {
56
+ results: validateActivityEventArray(normalizedResults),
57
+ nextCursor,
58
+ };
59
+ }
60
+ }
@@ -0,0 +1,366 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { z } from 'zod';
13
+ import { ENDPOINT_REST_APPS, ENDPOINT_REST_APPS_INSTALLATIONS, ENDPOINT_REST_USER_AUTHORIZATIONS, ENDPOINT_REST_USER_AUTHORIZATIONS_DELETE, getAppByDistributionTokenEndpoint, getAppClientSecretEndpoint, getAppDistributionTokenEndpoint, getAppEndpoint, getAppIconEndpoint, getAppInstallationEndpoint, getAppSecretsEndpoint, getAppTestTokenEndpoint, getAppTokensEndpoint, getAppVerificationTokenEndpoint, getAppWebhookEndpoint, } from '../consts/endpoints.js';
14
+ import { isSuccess, request } from '../transport/http-client.js';
15
+ import { webhookEventToWireName } from '../types/apps/index.js';
16
+ import { uploadMultipartFile } from '../utils/multipart-upload.js';
17
+ import { IdSchema, validateApp, validateAppArray, validateAppByDistributionToken, validateAppDistributionToken, validateAppInstallation, validateAppInstallationArray, validateAppSecrets, validateAppTestToken, validateAppVerificationToken, validateAppWebhook, validateAppWithUserCount, validateUserAuthorizationArray, } from '../utils/validators.js';
18
+ import { BaseClient } from './base-client.js';
19
+ /**
20
+ * Internal sub-client handling all developer-app management endpoints
21
+ * (apps, secrets, tokens, webhooks, installations, user authorizations).
22
+ * All endpoints require the `dev:app_console` OAuth scope.
23
+ *
24
+ * Instantiated by `TodoistApi`; every public app-management method on
25
+ * `TodoistApi` delegates here. See `todoist-api.ts` for user-facing JSDoc.
26
+ */
27
+ export class AppClient extends BaseClient {
28
+ async getApps(requestId) {
29
+ const response = await request({
30
+ httpMethod: 'GET',
31
+ baseUri: this.apiRootBase,
32
+ relativePath: ENDPOINT_REST_APPS,
33
+ apiToken: this.authToken,
34
+ customFetch: this.customFetch,
35
+ customHeaders: this.customHeaders,
36
+ requestId: requestId,
37
+ });
38
+ return validateAppArray(response.data);
39
+ }
40
+ async getApp(appId, requestId) {
41
+ IdSchema.parse(appId);
42
+ const response = await request({
43
+ httpMethod: 'GET',
44
+ baseUri: this.apiRootBase,
45
+ relativePath: getAppEndpoint(appId),
46
+ apiToken: this.authToken,
47
+ customFetch: this.customFetch,
48
+ customHeaders: this.customHeaders,
49
+ requestId: requestId,
50
+ });
51
+ return validateAppWithUserCount(response.data);
52
+ }
53
+ async addApp(args, requestId) {
54
+ const response = await request({
55
+ httpMethod: 'POST',
56
+ baseUri: this.apiRootBase,
57
+ relativePath: ENDPOINT_REST_APPS,
58
+ apiToken: this.authToken,
59
+ customFetch: this.customFetch,
60
+ customHeaders: this.customHeaders,
61
+ payload: args,
62
+ requestId: requestId,
63
+ });
64
+ return validateApp(response.data);
65
+ }
66
+ async updateApp(appId, args, requestId) {
67
+ IdSchema.parse(appId);
68
+ const { appTokenScopes } = args, rest = __rest(args, ["appTokenScopes"]);
69
+ const payload = Object.assign({}, rest);
70
+ if (appTokenScopes !== undefined) {
71
+ payload.appTokenScopes = appTokenScopes === null ? null : appTokenScopes.join(',');
72
+ }
73
+ const response = await request({
74
+ httpMethod: 'POST',
75
+ baseUri: this.apiRootBase,
76
+ relativePath: getAppEndpoint(appId),
77
+ apiToken: this.authToken,
78
+ customFetch: this.customFetch,
79
+ customHeaders: this.customHeaders,
80
+ payload: payload,
81
+ requestId: requestId,
82
+ });
83
+ return validateAppWithUserCount(response.data);
84
+ }
85
+ async deleteApp(appId, requestId) {
86
+ IdSchema.parse(appId);
87
+ const response = await request({
88
+ httpMethod: 'DELETE',
89
+ baseUri: this.apiRootBase,
90
+ relativePath: getAppEndpoint(appId),
91
+ apiToken: this.authToken,
92
+ customFetch: this.customFetch,
93
+ customHeaders: this.customHeaders,
94
+ requestId: requestId,
95
+ });
96
+ return isSuccess(response);
97
+ }
98
+ async getAppSecrets(appId, requestId) {
99
+ IdSchema.parse(appId);
100
+ const response = await request({
101
+ httpMethod: 'GET',
102
+ baseUri: this.apiRootBase,
103
+ relativePath: getAppSecretsEndpoint(appId),
104
+ apiToken: this.authToken,
105
+ customFetch: this.customFetch,
106
+ customHeaders: this.customHeaders,
107
+ requestId: requestId,
108
+ });
109
+ return validateAppSecrets(response.data);
110
+ }
111
+ async resetAppClientSecret(appId, requestId) {
112
+ IdSchema.parse(appId);
113
+ const response = await request({
114
+ httpMethod: 'DELETE',
115
+ baseUri: this.apiRootBase,
116
+ relativePath: getAppClientSecretEndpoint(appId),
117
+ apiToken: this.authToken,
118
+ customFetch: this.customFetch,
119
+ customHeaders: this.customHeaders,
120
+ requestId: requestId,
121
+ });
122
+ return validateAppWithUserCount(response.data);
123
+ }
124
+ async revokeAppTokens(appId, requestId) {
125
+ IdSchema.parse(appId);
126
+ const response = await request({
127
+ httpMethod: 'DELETE',
128
+ baseUri: this.apiRootBase,
129
+ relativePath: getAppTokensEndpoint(appId),
130
+ apiToken: this.authToken,
131
+ customFetch: this.customFetch,
132
+ customHeaders: this.customHeaders,
133
+ requestId: requestId,
134
+ });
135
+ return validateAppWithUserCount(response.data);
136
+ }
137
+ async uploadAppIcon({ appId, file, fileName = '', size = 'medium' }, requestId) {
138
+ IdSchema.parse(appId);
139
+ if (Buffer.isBuffer(file) && file.length === 0) {
140
+ throw new Error('Cannot upload empty image file');
141
+ }
142
+ const data = await uploadMultipartFile({
143
+ baseUrl: this.apiRootBase,
144
+ authToken: this.authToken,
145
+ endpoint: getAppIconEndpoint(appId, size),
146
+ file,
147
+ fileName,
148
+ additionalFields: { file_name: fileName },
149
+ requestId: requestId,
150
+ customFetch: this.customFetch,
151
+ customHeaders: this.customHeaders,
152
+ });
153
+ return validateAppWithUserCount(data);
154
+ }
155
+ async getAppTestToken(appId, requestId) {
156
+ IdSchema.parse(appId);
157
+ const response = await request({
158
+ httpMethod: 'GET',
159
+ baseUri: this.apiRootBase,
160
+ relativePath: getAppTestTokenEndpoint(appId),
161
+ apiToken: this.authToken,
162
+ customFetch: this.customFetch,
163
+ customHeaders: this.customHeaders,
164
+ requestId: requestId,
165
+ });
166
+ return validateAppTestToken(response.data);
167
+ }
168
+ async createAppTestToken(appId, requestId) {
169
+ IdSchema.parse(appId);
170
+ const response = await request({
171
+ httpMethod: 'PUT',
172
+ baseUri: this.apiRootBase,
173
+ relativePath: getAppTestTokenEndpoint(appId),
174
+ apiToken: this.authToken,
175
+ customFetch: this.customFetch,
176
+ customHeaders: this.customHeaders,
177
+ requestId: requestId,
178
+ });
179
+ return validateAppTestToken(response.data);
180
+ }
181
+ async getAppDistributionToken(appId, requestId) {
182
+ IdSchema.parse(appId);
183
+ const response = await request({
184
+ httpMethod: 'GET',
185
+ baseUri: this.apiRootBase,
186
+ relativePath: getAppDistributionTokenEndpoint(appId),
187
+ apiToken: this.authToken,
188
+ customFetch: this.customFetch,
189
+ customHeaders: this.customHeaders,
190
+ requestId: requestId,
191
+ });
192
+ return validateAppDistributionToken(response.data);
193
+ }
194
+ async getAppVerificationToken(appId, requestId) {
195
+ IdSchema.parse(appId);
196
+ const response = await request({
197
+ httpMethod: 'GET',
198
+ baseUri: this.apiRootBase,
199
+ relativePath: getAppVerificationTokenEndpoint(appId),
200
+ apiToken: this.authToken,
201
+ customFetch: this.customFetch,
202
+ customHeaders: this.customHeaders,
203
+ requestId: requestId,
204
+ });
205
+ return validateAppVerificationToken(response.data);
206
+ }
207
+ async resetAppVerificationToken(appId, requestId) {
208
+ IdSchema.parse(appId);
209
+ const response = await request({
210
+ httpMethod: 'DELETE',
211
+ baseUri: this.apiRootBase,
212
+ relativePath: getAppVerificationTokenEndpoint(appId),
213
+ apiToken: this.authToken,
214
+ customFetch: this.customFetch,
215
+ customHeaders: this.customHeaders,
216
+ requestId: requestId,
217
+ });
218
+ return validateAppVerificationToken(response.data);
219
+ }
220
+ async getAppByDistributionToken(distributionToken, requestId) {
221
+ z.string().min(1).parse(distributionToken);
222
+ const response = await request({
223
+ httpMethod: 'GET',
224
+ baseUri: this.apiRootBase,
225
+ relativePath: getAppByDistributionTokenEndpoint(distributionToken),
226
+ apiToken: this.authToken,
227
+ customFetch: this.customFetch,
228
+ customHeaders: this.customHeaders,
229
+ requestId: requestId,
230
+ });
231
+ return validateAppByDistributionToken(response.data);
232
+ }
233
+ // --- App webhooks ---
234
+ async getAppWebhook(appId, requestId) {
235
+ IdSchema.parse(appId);
236
+ const response = await request({
237
+ httpMethod: 'GET',
238
+ baseUri: this.apiRootBase,
239
+ relativePath: getAppWebhookEndpoint(appId),
240
+ apiToken: this.authToken,
241
+ customFetch: this.customFetch,
242
+ customHeaders: this.customHeaders,
243
+ requestId: requestId,
244
+ });
245
+ return response.data ? validateAppWebhook(response.data) : null;
246
+ }
247
+ async updateAppWebhook(args, requestId) {
248
+ const { appId, events } = args, rest = __rest(args, ["appId", "events"]);
249
+ const response = await request({
250
+ httpMethod: 'POST',
251
+ baseUri: this.apiRootBase,
252
+ relativePath: getAppWebhookEndpoint(appId),
253
+ apiToken: this.authToken,
254
+ customFetch: this.customFetch,
255
+ customHeaders: this.customHeaders,
256
+ payload: Object.assign(Object.assign({}, rest), { events: events.map(webhookEventToWireName) }),
257
+ requestId: requestId,
258
+ });
259
+ return validateAppWebhook(response.data);
260
+ }
261
+ async deleteAppWebhook(appId, requestId) {
262
+ IdSchema.parse(appId);
263
+ const response = await request({
264
+ httpMethod: 'DELETE',
265
+ baseUri: this.apiRootBase,
266
+ relativePath: getAppWebhookEndpoint(appId),
267
+ apiToken: this.authToken,
268
+ customFetch: this.customFetch,
269
+ customHeaders: this.customHeaders,
270
+ requestId: requestId,
271
+ });
272
+ return isSuccess(response);
273
+ }
274
+ // --- App installations ---
275
+ async getAppInstallations(requestId) {
276
+ const response = await request({
277
+ httpMethod: 'GET',
278
+ baseUri: this.apiRootBase,
279
+ relativePath: ENDPOINT_REST_APPS_INSTALLATIONS,
280
+ apiToken: this.authToken,
281
+ customFetch: this.customFetch,
282
+ customHeaders: this.customHeaders,
283
+ requestId: requestId,
284
+ });
285
+ return validateAppInstallationArray(response.data);
286
+ }
287
+ async installApp(args, requestId) {
288
+ const response = await request({
289
+ httpMethod: 'POST',
290
+ baseUri: this.apiRootBase,
291
+ relativePath: ENDPOINT_REST_APPS_INSTALLATIONS,
292
+ apiToken: this.authToken,
293
+ customFetch: this.customFetch,
294
+ customHeaders: this.customHeaders,
295
+ payload: args,
296
+ requestId: requestId,
297
+ });
298
+ return validateAppInstallation(response.data);
299
+ }
300
+ async getAppInstallation(installationId, requestId) {
301
+ IdSchema.parse(installationId);
302
+ const response = await request({
303
+ httpMethod: 'GET',
304
+ baseUri: this.apiRootBase,
305
+ relativePath: getAppInstallationEndpoint(installationId),
306
+ apiToken: this.authToken,
307
+ customFetch: this.customFetch,
308
+ customHeaders: this.customHeaders,
309
+ requestId: requestId,
310
+ });
311
+ return validateAppInstallation(response.data);
312
+ }
313
+ async updateAppInstallation(installationId, args, requestId) {
314
+ IdSchema.parse(installationId);
315
+ const response = await request({
316
+ httpMethod: 'POST',
317
+ baseUri: this.apiRootBase,
318
+ relativePath: getAppInstallationEndpoint(installationId),
319
+ apiToken: this.authToken,
320
+ customFetch: this.customFetch,
321
+ customHeaders: this.customHeaders,
322
+ payload: args,
323
+ requestId: requestId,
324
+ });
325
+ return validateAppInstallation(response.data);
326
+ }
327
+ async uninstallApp(installationId, requestId) {
328
+ IdSchema.parse(installationId);
329
+ const response = await request({
330
+ httpMethod: 'DELETE',
331
+ baseUri: this.apiRootBase,
332
+ relativePath: getAppInstallationEndpoint(installationId),
333
+ apiToken: this.authToken,
334
+ customFetch: this.customFetch,
335
+ customHeaders: this.customHeaders,
336
+ requestId: requestId,
337
+ });
338
+ return isSuccess(response);
339
+ }
340
+ // --- User authorizations ---
341
+ async getUserAuthorizations(requestId) {
342
+ const response = await request({
343
+ httpMethod: 'GET',
344
+ baseUri: this.apiRootBase,
345
+ relativePath: ENDPOINT_REST_USER_AUTHORIZATIONS,
346
+ apiToken: this.authToken,
347
+ customFetch: this.customFetch,
348
+ customHeaders: this.customHeaders,
349
+ requestId: requestId,
350
+ });
351
+ return validateUserAuthorizationArray(response.data);
352
+ }
353
+ async revokeUserAuthorization(args, requestId) {
354
+ const response = await request({
355
+ httpMethod: 'POST',
356
+ baseUri: this.apiRootBase,
357
+ relativePath: ENDPOINT_REST_USER_AUTHORIZATIONS_DELETE,
358
+ apiToken: this.authToken,
359
+ customFetch: this.customFetch,
360
+ customHeaders: this.customHeaders,
361
+ payload: args,
362
+ requestId: requestId,
363
+ });
364
+ return isSuccess(response);
365
+ }
366
+ }
@@ -0,0 +1,47 @@
1
+ import { ENDPOINT_REST_BACKUPS, ENDPOINT_REST_BACKUPS_DOWNLOAD } from '../consts/endpoints.js';
2
+ import { request } from '../transport/http-client.js';
3
+ import { wrapAsFileResponse } from '../utils/file-response.js';
4
+ import { mergeHeaders, resolveCustomHeaders } from '../utils/headers.js';
5
+ import { validateBackupArray } from '../utils/validators.js';
6
+ import { BaseClient } from './base-client.js';
7
+ /**
8
+ * Internal sub-client handling backup-domain endpoints.
9
+ *
10
+ * Instantiated by `TodoistApi`; every public backup method on
11
+ * `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
12
+ * JSDoc.
13
+ */
14
+ export class BackupClient extends BaseClient {
15
+ async getBackups(args = {}) {
16
+ const response = await request({
17
+ httpMethod: 'GET',
18
+ baseUri: this.syncApiBase,
19
+ relativePath: ENDPOINT_REST_BACKUPS,
20
+ apiToken: this.authToken,
21
+ customFetch: this.customFetch,
22
+ customHeaders: this.customHeaders,
23
+ payload: args,
24
+ });
25
+ return validateBackupArray(response.data);
26
+ }
27
+ async downloadBackup(args) {
28
+ const url = `${this.syncApiBase}${ENDPOINT_REST_BACKUPS_DOWNLOAD}?file=${encodeURIComponent(args.file)}`;
29
+ const fetchOptions = {
30
+ headers: mergeHeaders(resolveCustomHeaders(this.customHeaders), {
31
+ Authorization: `Bearer ${this.authToken}`,
32
+ }),
33
+ };
34
+ if (this.customFetch) {
35
+ const response = await this.customFetch(url, fetchOptions);
36
+ if (!response.ok) {
37
+ throw new Error(`Failed to download backup: ${response.status} ${response.statusText}`);
38
+ }
39
+ return wrapAsFileResponse(response, 'downloadBackup');
40
+ }
41
+ const response = await fetch(url, fetchOptions);
42
+ if (!response.ok) {
43
+ throw new Error(`Failed to download backup: ${response.status} ${response.statusText}`);
44
+ }
45
+ return wrapAsFileResponse(response, 'downloadBackup');
46
+ }
47
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Internal base class for every domain sub-client (tasks, projects, …).
3
+ *
4
+ * Not exported from the package — sub-clients are an implementation detail
5
+ * of `TodoistApi`. Holds the pieces of HTTP identity every sub-client
6
+ * needs and exposes a typed accessor to feed the Sync API helper.
7
+ *
8
+ * The constructor takes a {@link SyncRequestContext} — the same record
9
+ * shape used by `performSyncRequest` — so there is a single type describing
10
+ * "the HTTP identity an SDK component needs", not two types that must stay
11
+ * in sync.
12
+ */
13
+ export class BaseClient {
14
+ constructor(context) {
15
+ this.authToken = context.authToken;
16
+ this.syncApiBase = context.syncApiBase;
17
+ this.apiRootBase = new URL('/', context.syncApiBase).toString();
18
+ this.customFetch = context.customFetch;
19
+ this.customHeaders = context.customHeaders;
20
+ }
21
+ get syncContext() {
22
+ return {
23
+ authToken: this.authToken,
24
+ syncApiBase: this.syncApiBase,
25
+ customFetch: this.customFetch,
26
+ customHeaders: this.customHeaders,
27
+ };
28
+ }
29
+ }
@@ -0,0 +1,160 @@
1
+ import { ENDPOINT_PAYMENTS_CANCEL_PLAN, ENDPOINT_PAYMENTS_REACTIVATE_PLAN, ENDPOINT_PAYMENTS_SUBSCRIPTION_INFO, ENDPOINT_PRICES, ENDPOINT_PRICING, ENDPOINT_PRO_BILLING_PORTAL, ENDPOINT_PRO_PLAN_DETAILS, ENDPOINT_PRO_TRIAL, ENDPOINT_PRO_UPGRADE, ENDPOINT_WORKSPACE_BILLING_PORTAL, ENDPOINT_WORKSPACE_TRIAL, ENDPOINT_WORKSPACE_UPGRADE, } from '../consts/endpoints.js';
2
+ import { request } from '../transport/http-client.js';
3
+ import { validatePricing, validatePrices, validateProPlanDetails, validateSubscriptionInfo, } from '../utils/validators.js';
4
+ import { BaseClient } from './base-client.js';
5
+ /**
6
+ * Internal sub-client handling all billing-domain endpoints.
7
+ *
8
+ * Instantiated by `TodoistApi`; every public billing method on `TodoistApi`
9
+ * delegates here. See `todoist-api.ts` for the user-facing JSDoc.
10
+ */
11
+ export class BillingClient extends BaseClient {
12
+ async getSubscriptionInfo() {
13
+ const response = await request({
14
+ httpMethod: 'POST',
15
+ baseUri: this.syncApiBase,
16
+ relativePath: ENDPOINT_PAYMENTS_SUBSCRIPTION_INFO,
17
+ apiToken: this.authToken,
18
+ customFetch: this.customFetch,
19
+ customHeaders: this.customHeaders,
20
+ });
21
+ return validateSubscriptionInfo(response.data);
22
+ }
23
+ async cancelPlan(args, requestId) {
24
+ const response = await request({
25
+ httpMethod: 'POST',
26
+ baseUri: this.syncApiBase,
27
+ relativePath: ENDPOINT_PAYMENTS_CANCEL_PLAN,
28
+ apiToken: this.authToken,
29
+ customFetch: this.customFetch,
30
+ customHeaders: this.customHeaders,
31
+ payload: args,
32
+ requestId: requestId,
33
+ });
34
+ return response.data;
35
+ }
36
+ async reactivatePlan(requestId) {
37
+ const response = await request({
38
+ httpMethod: 'POST',
39
+ baseUri: this.syncApiBase,
40
+ relativePath: ENDPOINT_PAYMENTS_REACTIVATE_PLAN,
41
+ apiToken: this.authToken,
42
+ customFetch: this.customFetch,
43
+ customHeaders: this.customHeaders,
44
+ requestId: requestId,
45
+ });
46
+ return validateSubscriptionInfo(response.data);
47
+ }
48
+ async upgradeToPro(args, requestId) {
49
+ const response = await request({
50
+ httpMethod: 'POST',
51
+ baseUri: this.syncApiBase,
52
+ relativePath: ENDPOINT_PRO_UPGRADE,
53
+ apiToken: this.authToken,
54
+ customFetch: this.customFetch,
55
+ customHeaders: this.customHeaders,
56
+ payload: args,
57
+ requestId: requestId,
58
+ });
59
+ return response.data;
60
+ }
61
+ async startProTrial(args, requestId) {
62
+ const response = await request({
63
+ httpMethod: 'POST',
64
+ baseUri: this.syncApiBase,
65
+ relativePath: ENDPOINT_PRO_TRIAL,
66
+ apiToken: this.authToken,
67
+ customFetch: this.customFetch,
68
+ customHeaders: this.customHeaders,
69
+ payload: args,
70
+ requestId: requestId,
71
+ });
72
+ return response.data;
73
+ }
74
+ async createProBillingPortalSession(args, requestId) {
75
+ const response = await request({
76
+ httpMethod: 'POST',
77
+ baseUri: this.syncApiBase,
78
+ relativePath: ENDPOINT_PRO_BILLING_PORTAL,
79
+ apiToken: this.authToken,
80
+ customFetch: this.customFetch,
81
+ customHeaders: this.customHeaders,
82
+ payload: args,
83
+ requestId: requestId,
84
+ });
85
+ return response.data;
86
+ }
87
+ async getProPlanDetails() {
88
+ const response = await request({
89
+ httpMethod: 'GET',
90
+ baseUri: this.syncApiBase,
91
+ relativePath: ENDPOINT_PRO_PLAN_DETAILS,
92
+ apiToken: this.authToken,
93
+ customFetch: this.customFetch,
94
+ customHeaders: this.customHeaders,
95
+ });
96
+ return validateProPlanDetails(response.data);
97
+ }
98
+ async upgradeWorkspace(args, requestId) {
99
+ const response = await request({
100
+ httpMethod: 'POST',
101
+ baseUri: this.syncApiBase,
102
+ relativePath: ENDPOINT_WORKSPACE_UPGRADE,
103
+ apiToken: this.authToken,
104
+ customFetch: this.customFetch,
105
+ customHeaders: this.customHeaders,
106
+ payload: args,
107
+ requestId: requestId,
108
+ });
109
+ return response.data;
110
+ }
111
+ async startWorkspaceTrial(args, requestId) {
112
+ const response = await request({
113
+ httpMethod: 'POST',
114
+ baseUri: this.syncApiBase,
115
+ relativePath: ENDPOINT_WORKSPACE_TRIAL,
116
+ apiToken: this.authToken,
117
+ customFetch: this.customFetch,
118
+ customHeaders: this.customHeaders,
119
+ payload: args,
120
+ requestId: requestId,
121
+ });
122
+ return response.data;
123
+ }
124
+ async createWorkspaceBillingPortalSession(args, requestId) {
125
+ const response = await request({
126
+ httpMethod: 'POST',
127
+ baseUri: this.syncApiBase,
128
+ relativePath: ENDPOINT_WORKSPACE_BILLING_PORTAL,
129
+ apiToken: this.authToken,
130
+ customFetch: this.customFetch,
131
+ customHeaders: this.customHeaders,
132
+ payload: args,
133
+ requestId: requestId,
134
+ });
135
+ return response.data;
136
+ }
137
+ async getPrices() {
138
+ const response = await request({
139
+ httpMethod: 'GET',
140
+ baseUri: this.syncApiBase,
141
+ relativePath: ENDPOINT_PRICES,
142
+ apiToken: this.authToken,
143
+ customFetch: this.customFetch,
144
+ customHeaders: this.customHeaders,
145
+ });
146
+ return validatePrices(response.data);
147
+ }
148
+ async getPricing(args) {
149
+ const response = await request({
150
+ httpMethod: 'GET',
151
+ baseUri: this.syncApiBase,
152
+ relativePath: ENDPOINT_PRICING,
153
+ apiToken: this.authToken,
154
+ customFetch: this.customFetch,
155
+ customHeaders: this.customHeaders,
156
+ payload: args,
157
+ });
158
+ return validatePricing(response.data);
159
+ }
160
+ }