@doist/todoist-sdk 14.2.0 → 15.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/dist/esm/utils/index.js +1 -1
  2. package/dist/esm/utils/url-helpers.js +151 -23
  3. package/dist/types/utils/index.d.ts +2 -1
  4. package/dist/types/utils/url-helpers.d.ts +88 -0
  5. package/package.json +5 -10
  6. package/dist/cjs/authentication.js +0 -317
  7. package/dist/cjs/clients/activity-client.js +0 -63
  8. package/dist/cjs/clients/app-client.js +0 -345
  9. package/dist/cjs/clients/backup-client.js +0 -47
  10. package/dist/cjs/clients/base-client.js +0 -31
  11. package/dist/cjs/clients/billing-client.js +0 -152
  12. package/dist/cjs/clients/comment-client.js +0 -91
  13. package/dist/cjs/clients/email-client.js +0 -43
  14. package/dist/cjs/clients/folder-client.js +0 -79
  15. package/dist/cjs/clients/id-mapping-client.js +0 -39
  16. package/dist/cjs/clients/insights-client.js +0 -87
  17. package/dist/cjs/clients/label-client.js +0 -126
  18. package/dist/cjs/clients/productivity-client.js +0 -27
  19. package/dist/cjs/clients/project-client.js +0 -235
  20. package/dist/cjs/clients/reminder-client.js +0 -198
  21. package/dist/cjs/clients/section-client.js +0 -117
  22. package/dist/cjs/clients/task-client.js +0 -254
  23. package/dist/cjs/clients/template-client.js +0 -88
  24. package/dist/cjs/clients/ui-extension-client.js +0 -107
  25. package/dist/cjs/clients/upload-client.js +0 -155
  26. package/dist/cjs/clients/view-options-client.js +0 -25
  27. package/dist/cjs/clients/workspace-client.js +0 -366
  28. package/dist/cjs/consts/endpoints.js +0 -224
  29. package/dist/cjs/index.js +0 -24
  30. package/dist/cjs/package.json +0 -1
  31. package/dist/cjs/test-utils/asserts.js +0 -11
  32. package/dist/cjs/test-utils/msw-setup.js +0 -97
  33. package/dist/cjs/test-utils/obsidian-fetch-adapter.js +0 -54
  34. package/dist/cjs/test-utils/test-defaults.js +0 -371
  35. package/dist/cjs/test-utils/transport-seam.js +0 -17
  36. package/dist/cjs/test-utils/webhook-fixtures.js +0 -32
  37. package/dist/cjs/todoist-api.js +0 -1711
  38. package/dist/cjs/transport/fetch-with-retry.js +0 -219
  39. package/dist/cjs/transport/http-client.js +0 -134
  40. package/dist/cjs/transport/http-dispatcher.js +0 -198
  41. package/dist/cjs/transport/sync-request.js +0 -83
  42. package/dist/cjs/types/activity/index.js +0 -18
  43. package/dist/cjs/types/activity/requests.js +0 -2
  44. package/dist/cjs/types/activity/types.js +0 -28
  45. package/dist/cjs/types/apps/index.js +0 -18
  46. package/dist/cjs/types/apps/requests.js +0 -2
  47. package/dist/cjs/types/apps/types.js +0 -254
  48. package/dist/cjs/types/backups/index.js +0 -18
  49. package/dist/cjs/types/backups/requests.js +0 -2
  50. package/dist/cjs/types/backups/types.js +0 -8
  51. package/dist/cjs/types/billing/index.js +0 -18
  52. package/dist/cjs/types/billing/requests.js +0 -2
  53. package/dist/cjs/types/billing/types.js +0 -92
  54. package/dist/cjs/types/comments/index.js +0 -18
  55. package/dist/cjs/types/comments/requests.js +0 -2
  56. package/dist/cjs/types/comments/types.js +0 -60
  57. package/dist/cjs/types/common.js +0 -10
  58. package/dist/cjs/types/emails/index.js +0 -17
  59. package/dist/cjs/types/emails/requests.js +0 -5
  60. package/dist/cjs/types/errors.js +0 -29
  61. package/dist/cjs/types/folders/index.js +0 -17
  62. package/dist/cjs/types/folders/requests.js +0 -2
  63. package/dist/cjs/types/http.js +0 -24
  64. package/dist/cjs/types/id-mappings/index.js +0 -18
  65. package/dist/cjs/types/id-mappings/requests.js +0 -20
  66. package/dist/cjs/types/id-mappings/types.js +0 -12
  67. package/dist/cjs/types/index.js +0 -40
  68. package/dist/cjs/types/insights/index.js +0 -18
  69. package/dist/cjs/types/insights/requests.js +0 -2
  70. package/dist/cjs/types/insights/types.js +0 -80
  71. package/dist/cjs/types/labels/index.js +0 -18
  72. package/dist/cjs/types/labels/requests.js +0 -2
  73. package/dist/cjs/types/labels/types.js +0 -11
  74. package/dist/cjs/types/productivity/index.js +0 -17
  75. package/dist/cjs/types/productivity/types.js +0 -68
  76. package/dist/cjs/types/projects/index.js +0 -18
  77. package/dist/cjs/types/projects/requests.js +0 -2
  78. package/dist/cjs/types/projects/types.js +0 -66
  79. package/dist/cjs/types/reminders/index.js +0 -17
  80. package/dist/cjs/types/reminders/requests.js +0 -95
  81. package/dist/cjs/types/sections/index.js +0 -18
  82. package/dist/cjs/types/sections/requests.js +0 -2
  83. package/dist/cjs/types/sections/types.js +0 -25
  84. package/dist/cjs/types/sync/commands/calendars.js +0 -2
  85. package/dist/cjs/types/sync/commands/filters.js +0 -2
  86. package/dist/cjs/types/sync/commands/folders.js +0 -2
  87. package/dist/cjs/types/sync/commands/index.js +0 -34
  88. package/dist/cjs/types/sync/commands/labels.js +0 -5
  89. package/dist/cjs/types/sync/commands/notes.js +0 -2
  90. package/dist/cjs/types/sync/commands/notifications.js +0 -2
  91. package/dist/cjs/types/sync/commands/others.js +0 -2
  92. package/dist/cjs/types/sync/commands/project-view-options.js +0 -2
  93. package/dist/cjs/types/sync/commands/projects.js +0 -2
  94. package/dist/cjs/types/sync/commands/reminders.js +0 -2
  95. package/dist/cjs/types/sync/commands/sections.js +0 -2
  96. package/dist/cjs/types/sync/commands/shared.js +0 -20
  97. package/dist/cjs/types/sync/commands/sharing.js +0 -2
  98. package/dist/cjs/types/sync/commands/tasks.js +0 -2
  99. package/dist/cjs/types/sync/commands/view-options.js +0 -2
  100. package/dist/cjs/types/sync/commands/workspace-filters.js +0 -2
  101. package/dist/cjs/types/sync/commands/workspaces.js +0 -2
  102. package/dist/cjs/types/sync/index.js +0 -22
  103. package/dist/cjs/types/sync/request.js +0 -2
  104. package/dist/cjs/types/sync/resource-types.js +0 -39
  105. package/dist/cjs/types/sync/resources/calendars.js +0 -27
  106. package/dist/cjs/types/sync/resources/collaborators.js +0 -21
  107. package/dist/cjs/types/sync/resources/completed-info.js +0 -24
  108. package/dist/cjs/types/sync/resources/filters.js +0 -14
  109. package/dist/cjs/types/sync/resources/folders.js +0 -12
  110. package/dist/cjs/types/sync/resources/index.js +0 -32
  111. package/dist/cjs/types/sync/resources/live-notifications.js +0 -38
  112. package/dist/cjs/types/sync/resources/notes.js +0 -21
  113. package/dist/cjs/types/sync/resources/reminders.js +0 -50
  114. package/dist/cjs/types/sync/resources/suggestions.js +0 -36
  115. package/dist/cjs/types/sync/resources/tooltips.js +0 -8
  116. package/dist/cjs/types/sync/resources/user-plan-limits.js +0 -20
  117. package/dist/cjs/types/sync/resources/user-settings.js +0 -40
  118. package/dist/cjs/types/sync/resources/user.js +0 -110
  119. package/dist/cjs/types/sync/resources/view-options.js +0 -86
  120. package/dist/cjs/types/sync/resources/workspace-filters.js +0 -19
  121. package/dist/cjs/types/sync/resources/workspaces.js +0 -72
  122. package/dist/cjs/types/sync/response.js +0 -54
  123. package/dist/cjs/types/sync/user-preferences.js +0 -71
  124. package/dist/cjs/types/tasks/index.js +0 -18
  125. package/dist/cjs/types/tasks/requests.js +0 -2
  126. package/dist/cjs/types/tasks/types.js +0 -59
  127. package/dist/cjs/types/templates/index.js +0 -17
  128. package/dist/cjs/types/templates/requests.js +0 -2
  129. package/dist/cjs/types/ui-extensions/index.js +0 -18
  130. package/dist/cjs/types/ui-extensions/requests.js +0 -2
  131. package/dist/cjs/types/ui-extensions/types.js +0 -77
  132. package/dist/cjs/types/uploads/index.js +0 -17
  133. package/dist/cjs/types/uploads/requests.js +0 -2
  134. package/dist/cjs/types/users/index.js +0 -17
  135. package/dist/cjs/types/users/types.js +0 -51
  136. package/dist/cjs/types/webhooks/comments.js +0 -96
  137. package/dist/cjs/types/webhooks/envelope.js +0 -26
  138. package/dist/cjs/types/webhooks/filters.js +0 -30
  139. package/dist/cjs/types/webhooks/index.js +0 -25
  140. package/dist/cjs/types/webhooks/labels.js +0 -54
  141. package/dist/cjs/types/webhooks/projects.js +0 -36
  142. package/dist/cjs/types/webhooks/reminders.js +0 -35
  143. package/dist/cjs/types/webhooks/sections.js +0 -53
  144. package/dist/cjs/types/webhooks/tasks.js +0 -68
  145. package/dist/cjs/types/webhooks/types.js +0 -55
  146. package/dist/cjs/types/workspaces/index.js +0 -18
  147. package/dist/cjs/types/workspaces/requests.js +0 -2
  148. package/dist/cjs/types/workspaces/types.js +0 -154
  149. package/dist/cjs/utils/activity-helpers.js +0 -58
  150. package/dist/cjs/utils/case-conversion.js +0 -69
  151. package/dist/cjs/utils/colors.js +0 -143
  152. package/dist/cjs/utils/file-response.js +0 -32
  153. package/dist/cjs/utils/headers.js +0 -16
  154. package/dist/cjs/utils/index.js +0 -31
  155. package/dist/cjs/utils/multipart-upload.js +0 -293
  156. package/dist/cjs/utils/processing-helpers.js +0 -18
  157. package/dist/cjs/utils/project-helpers.js +0 -20
  158. package/dist/cjs/utils/request-helpers.js +0 -21
  159. package/dist/cjs/utils/sanitization.js +0 -116
  160. package/dist/cjs/utils/sync-helpers.js +0 -22
  161. package/dist/cjs/utils/task-sorting.js +0 -281
  162. package/dist/cjs/utils/uncompletable-helpers.js +0 -60
  163. package/dist/cjs/utils/url-helpers.js +0 -74
  164. package/dist/cjs/utils/validators.js +0 -108
  165. package/dist/cjs/utils/view-options.js +0 -19
  166. package/dist/cjs/utils/webhook-parser.js +0 -60
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EmailClient = void 0;
4
- const endpoints_1 = require("../consts/endpoints");
5
- const http_client_1 = require("../transport/http-client");
6
- const base_client_1 = require("./base-client");
7
- /**
8
- * Internal sub-client handling email-forwarding endpoints.
9
- *
10
- * Instantiated by `TodoistApi`; every public email-forwarding method on
11
- * `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
12
- * JSDoc.
13
- */
14
- class EmailClient extends base_client_1.BaseClient {
15
- async getOrCreateEmailForwarding(args, requestId) {
16
- const { data } = await (0, http_client_1.request)({
17
- httpMethod: 'PUT',
18
- baseUri: this.syncApiBase,
19
- relativePath: endpoints_1.ENDPOINT_REST_EMAILS,
20
- apiToken: this.authToken,
21
- customFetch: this.customFetch,
22
- payload: args,
23
- requestId: requestId,
24
- });
25
- return data;
26
- }
27
- async disableEmailForwarding(args, requestId) {
28
- const queryParams = new URLSearchParams({
29
- obj_type: args.objType,
30
- obj_id: args.objId,
31
- });
32
- const response = await (0, http_client_1.request)({
33
- httpMethod: 'DELETE',
34
- baseUri: this.syncApiBase,
35
- relativePath: `${endpoints_1.ENDPOINT_REST_EMAILS}?${queryParams.toString()}`,
36
- apiToken: this.authToken,
37
- customFetch: this.customFetch,
38
- requestId: requestId,
39
- });
40
- return (0, http_client_1.isSuccess)(response);
41
- }
42
- }
43
- exports.EmailClient = EmailClient;
@@ -1,79 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FolderClient = void 0;
4
- const endpoints_1 = require("../consts/endpoints");
5
- const http_client_1 = require("../transport/http-client");
6
- const request_helpers_1 = require("../utils/request-helpers");
7
- const validators_1 = require("../utils/validators");
8
- const base_client_1 = require("./base-client");
9
- /**
10
- * Internal sub-client handling all folder-domain endpoints.
11
- *
12
- * Instantiated by `TodoistApi`; every public folder method on `TodoistApi`
13
- * delegates here. See `todoist-api.ts` for the user-facing JSDoc.
14
- */
15
- class FolderClient extends base_client_1.BaseClient {
16
- async getFolders(args) {
17
- const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
18
- httpMethod: 'GET',
19
- baseUri: this.syncApiBase,
20
- relativePath: endpoints_1.ENDPOINT_REST_FOLDERS,
21
- apiToken: this.authToken,
22
- customFetch: this.customFetch,
23
- payload: args,
24
- });
25
- return {
26
- results: (0, validators_1.validateFolderArray)(results),
27
- nextCursor,
28
- };
29
- }
30
- async getFolder(id) {
31
- validators_1.IdSchema.parse(id);
32
- const response = await (0, http_client_1.request)({
33
- httpMethod: 'GET',
34
- baseUri: this.syncApiBase,
35
- relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_FOLDERS, id),
36
- apiToken: this.authToken,
37
- customFetch: this.customFetch,
38
- });
39
- return (0, validators_1.validateFolder)(response.data);
40
- }
41
- async addFolder(args, requestId) {
42
- const response = await (0, http_client_1.request)({
43
- httpMethod: 'POST',
44
- baseUri: this.syncApiBase,
45
- relativePath: endpoints_1.ENDPOINT_REST_FOLDERS,
46
- apiToken: this.authToken,
47
- customFetch: this.customFetch,
48
- payload: args,
49
- requestId: requestId,
50
- });
51
- return (0, validators_1.validateFolder)(response.data);
52
- }
53
- async updateFolder(id, args, requestId) {
54
- validators_1.IdSchema.parse(id);
55
- const response = await (0, http_client_1.request)({
56
- httpMethod: 'POST',
57
- baseUri: this.syncApiBase,
58
- relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_FOLDERS, id),
59
- apiToken: this.authToken,
60
- customFetch: this.customFetch,
61
- payload: args,
62
- requestId: requestId,
63
- });
64
- return (0, validators_1.validateFolder)(response.data);
65
- }
66
- async deleteFolder(id, requestId) {
67
- validators_1.IdSchema.parse(id);
68
- const response = await (0, http_client_1.request)({
69
- httpMethod: 'DELETE',
70
- baseUri: this.syncApiBase,
71
- relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_FOLDERS, id),
72
- apiToken: this.authToken,
73
- customFetch: this.customFetch,
74
- requestId: requestId,
75
- });
76
- return (0, http_client_1.isSuccess)(response);
77
- }
78
- }
79
- exports.FolderClient = FolderClient;
@@ -1,39 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IdMappingClient = void 0;
4
- const endpoints_1 = require("../consts/endpoints");
5
- const http_client_1 = require("../transport/http-client");
6
- const request_helpers_1 = require("../utils/request-helpers");
7
- const validators_1 = require("../utils/validators");
8
- const base_client_1 = require("./base-client");
9
- /**
10
- * Internal sub-client handling ID-mapping endpoints.
11
- *
12
- * Instantiated by `TodoistApi`; every public id-mapping method on
13
- * `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
14
- * JSDoc.
15
- */
16
- class IdMappingClient extends base_client_1.BaseClient {
17
- async getIdMappings(args) {
18
- const response = await (0, http_client_1.request)({
19
- httpMethod: 'GET',
20
- baseUri: this.syncApiBase,
21
- relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_ID_MAPPINGS, args.objName, args.objIds.join(',')),
22
- apiToken: this.authToken,
23
- customFetch: this.customFetch,
24
- });
25
- return (0, validators_1.validateIdMappingArray)(response.data);
26
- }
27
- async getMovedIds(args) {
28
- const response = await (0, http_client_1.request)({
29
- httpMethod: 'GET',
30
- baseUri: this.syncApiBase,
31
- relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_MOVED_IDS, args.objName),
32
- apiToken: this.authToken,
33
- customFetch: this.customFetch,
34
- payload: args.oldIds ? { oldIds: args.oldIds.join(',') } : undefined,
35
- });
36
- return (0, validators_1.validateMovedIdArray)(response.data);
37
- }
38
- }
39
- exports.IdMappingClient = IdMappingClient;
@@ -1,87 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InsightsClient = void 0;
4
- const endpoints_1 = require("../consts/endpoints");
5
- const http_client_1 = require("../transport/http-client");
6
- const validators_1 = require("../utils/validators");
7
- const base_client_1 = require("./base-client");
8
- /**
9
- * Internal sub-client handling all insights-domain endpoints
10
- * (project activity stats, health, progress, workspace insights).
11
- *
12
- * Instantiated by `TodoistApi`; every public insights method on
13
- * `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
14
- * JSDoc.
15
- */
16
- class InsightsClient extends base_client_1.BaseClient {
17
- async getProjectActivityStats(projectId, args = {}) {
18
- validators_1.IdSchema.parse(projectId);
19
- const response = await (0, http_client_1.request)({
20
- httpMethod: 'GET',
21
- baseUri: this.syncApiBase,
22
- relativePath: (0, endpoints_1.getProjectInsightsActivityStatsEndpoint)(projectId),
23
- apiToken: this.authToken,
24
- customFetch: this.customFetch,
25
- payload: Object.assign({ objectType: 'ITEM', eventType: 'COMPLETED' }, args),
26
- });
27
- return (0, validators_1.validateProjectActivityStats)(response.data);
28
- }
29
- async getProjectHealth(projectId) {
30
- validators_1.IdSchema.parse(projectId);
31
- const response = await (0, http_client_1.request)({
32
- httpMethod: 'GET',
33
- baseUri: this.syncApiBase,
34
- relativePath: (0, endpoints_1.getProjectInsightsHealthEndpoint)(projectId),
35
- apiToken: this.authToken,
36
- customFetch: this.customFetch,
37
- });
38
- return (0, validators_1.validateProjectHealth)(response.data);
39
- }
40
- async getProjectHealthContext(projectId) {
41
- validators_1.IdSchema.parse(projectId);
42
- const response = await (0, http_client_1.request)({
43
- httpMethod: 'GET',
44
- baseUri: this.syncApiBase,
45
- relativePath: (0, endpoints_1.getProjectInsightsHealthContextEndpoint)(projectId),
46
- apiToken: this.authToken,
47
- customFetch: this.customFetch,
48
- });
49
- return (0, validators_1.validateProjectHealthContext)(response.data);
50
- }
51
- async getProjectProgress(projectId) {
52
- validators_1.IdSchema.parse(projectId);
53
- const response = await (0, http_client_1.request)({
54
- httpMethod: 'GET',
55
- baseUri: this.syncApiBase,
56
- relativePath: (0, endpoints_1.getProjectInsightsProgressEndpoint)(projectId),
57
- apiToken: this.authToken,
58
- customFetch: this.customFetch,
59
- });
60
- return (0, validators_1.validateProjectProgress)(response.data);
61
- }
62
- async getWorkspaceInsights(workspaceId, args = {}) {
63
- validators_1.IdSchema.parse(workspaceId);
64
- const response = await (0, http_client_1.request)({
65
- httpMethod: 'GET',
66
- baseUri: this.syncApiBase,
67
- relativePath: (0, endpoints_1.getWorkspaceInsightsEndpoint)(workspaceId),
68
- apiToken: this.authToken,
69
- customFetch: this.customFetch,
70
- payload: Object.assign(Object.assign({}, args), (args.projectIds ? { projectIds: args.projectIds.join(',') } : {})),
71
- });
72
- return (0, validators_1.validateWorkspaceInsights)(response.data);
73
- }
74
- async analyzeProjectHealth(projectId, requestId) {
75
- validators_1.IdSchema.parse(projectId);
76
- const response = await (0, http_client_1.request)({
77
- httpMethod: 'POST',
78
- baseUri: this.syncApiBase,
79
- relativePath: (0, endpoints_1.getProjectInsightsHealthAnalyzeEndpoint)(projectId),
80
- apiToken: this.authToken,
81
- customFetch: this.customFetch,
82
- requestId: requestId,
83
- });
84
- return (0, validators_1.validateProjectHealth)(response.data);
85
- }
86
- }
87
- exports.InsightsClient = InsightsClient;
@@ -1,126 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LabelClient = void 0;
4
- const endpoints_1 = require("../consts/endpoints");
5
- const http_client_1 = require("../transport/http-client");
6
- const request_helpers_1 = require("../utils/request-helpers");
7
- const validators_1 = require("../utils/validators");
8
- const base_client_1 = require("./base-client");
9
- /**
10
- * Internal sub-client handling all label-domain endpoints.
11
- *
12
- * Instantiated by `TodoistApi`; every public label method on `TodoistApi`
13
- * delegates here. See `todoist-api.ts` for the user-facing JSDoc.
14
- */
15
- class LabelClient extends base_client_1.BaseClient {
16
- async getLabel(id) {
17
- validators_1.IdSchema.parse(id);
18
- const response = await (0, http_client_1.request)({
19
- httpMethod: 'GET',
20
- baseUri: this.syncApiBase,
21
- relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_LABELS, id),
22
- apiToken: this.authToken,
23
- customFetch: this.customFetch,
24
- });
25
- return (0, validators_1.validateLabel)(response.data);
26
- }
27
- async getLabels(args = {}) {
28
- const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
29
- httpMethod: 'GET',
30
- baseUri: this.syncApiBase,
31
- relativePath: endpoints_1.ENDPOINT_REST_LABELS,
32
- apiToken: this.authToken,
33
- customFetch: this.customFetch,
34
- payload: args,
35
- });
36
- return {
37
- results: (0, validators_1.validateLabelArray)(results),
38
- nextCursor,
39
- };
40
- }
41
- async searchLabels(args) {
42
- const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
43
- httpMethod: 'GET',
44
- baseUri: this.syncApiBase,
45
- relativePath: endpoints_1.ENDPOINT_REST_LABELS_SEARCH,
46
- apiToken: this.authToken,
47
- customFetch: this.customFetch,
48
- payload: args,
49
- });
50
- return {
51
- results: (0, validators_1.validateLabelArray)(results),
52
- nextCursor,
53
- };
54
- }
55
- async addLabel(args, requestId) {
56
- const response = await (0, http_client_1.request)({
57
- httpMethod: 'POST',
58
- baseUri: this.syncApiBase,
59
- relativePath: endpoints_1.ENDPOINT_REST_LABELS,
60
- apiToken: this.authToken,
61
- customFetch: this.customFetch,
62
- payload: args,
63
- requestId: requestId,
64
- });
65
- return (0, validators_1.validateLabel)(response.data);
66
- }
67
- async updateLabel(id, args, requestId) {
68
- validators_1.IdSchema.parse(id);
69
- const response = await (0, http_client_1.request)({
70
- httpMethod: 'POST',
71
- baseUri: this.syncApiBase,
72
- relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_LABELS, id),
73
- apiToken: this.authToken,
74
- customFetch: this.customFetch,
75
- payload: args,
76
- requestId: requestId,
77
- });
78
- return (0, validators_1.validateLabel)(response.data);
79
- }
80
- async deleteLabel(id, requestId) {
81
- validators_1.IdSchema.parse(id);
82
- const response = await (0, http_client_1.request)({
83
- httpMethod: 'DELETE',
84
- baseUri: this.syncApiBase,
85
- relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_LABELS, id),
86
- apiToken: this.authToken,
87
- customFetch: this.customFetch,
88
- requestId: requestId,
89
- });
90
- return (0, http_client_1.isSuccess)(response);
91
- }
92
- async getSharedLabels(args) {
93
- const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
94
- httpMethod: 'GET',
95
- baseUri: this.syncApiBase,
96
- relativePath: endpoints_1.ENDPOINT_REST_LABELS_SHARED,
97
- apiToken: this.authToken,
98
- customFetch: this.customFetch,
99
- payload: args,
100
- });
101
- return { results, nextCursor };
102
- }
103
- async renameSharedLabel(args) {
104
- const response = await (0, http_client_1.request)({
105
- httpMethod: 'POST',
106
- baseUri: this.syncApiBase,
107
- relativePath: endpoints_1.ENDPOINT_REST_LABELS_SHARED_RENAME,
108
- apiToken: this.authToken,
109
- customFetch: this.customFetch,
110
- payload: args,
111
- });
112
- return (0, http_client_1.isSuccess)(response);
113
- }
114
- async removeSharedLabel(args) {
115
- const response = await (0, http_client_1.request)({
116
- httpMethod: 'POST',
117
- baseUri: this.syncApiBase,
118
- relativePath: endpoints_1.ENDPOINT_REST_LABELS_SHARED_REMOVE,
119
- apiToken: this.authToken,
120
- customFetch: this.customFetch,
121
- payload: args,
122
- });
123
- return (0, http_client_1.isSuccess)(response);
124
- }
125
- }
126
- exports.LabelClient = LabelClient;
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ProductivityClient = void 0;
4
- const endpoints_1 = require("../consts/endpoints");
5
- const http_client_1 = require("../transport/http-client");
6
- const validators_1 = require("../utils/validators");
7
- const base_client_1 = require("./base-client");
8
- /**
9
- * Internal sub-client handling the productivity-stats endpoint.
10
- *
11
- * Instantiated by `TodoistApi`; the public `getProductivityStats` method
12
- * on `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
13
- * JSDoc.
14
- */
15
- class ProductivityClient extends base_client_1.BaseClient {
16
- async getProductivityStats() {
17
- const response = await (0, http_client_1.request)({
18
- httpMethod: 'GET',
19
- baseUri: this.syncApiBase,
20
- relativePath: endpoints_1.ENDPOINT_REST_PRODUCTIVITY,
21
- apiToken: this.authToken,
22
- customFetch: this.customFetch,
23
- });
24
- return (0, validators_1.validateProductivityStats)(response.data);
25
- }
26
- }
27
- exports.ProductivityClient = ProductivityClient;
@@ -1,235 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ProjectClient = void 0;
4
- const endpoints_1 = require("../consts/endpoints");
5
- const http_client_1 = require("../transport/http-client");
6
- const request_helpers_1 = require("../utils/request-helpers");
7
- const validators_1 = require("../utils/validators");
8
- const base_client_1 = require("./base-client");
9
- /**
10
- * Internal sub-client handling all project-domain endpoints.
11
- *
12
- * Instantiated by `TodoistApi`; every public project method on `TodoistApi`
13
- * delegates here. See `todoist-api.ts` for the user-facing JSDoc.
14
- */
15
- class ProjectClient extends base_client_1.BaseClient {
16
- async getProject(id) {
17
- validators_1.IdSchema.parse(id);
18
- const response = await (0, http_client_1.request)({
19
- httpMethod: 'GET',
20
- baseUri: this.syncApiBase,
21
- relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_PROJECTS, id),
22
- apiToken: this.authToken,
23
- customFetch: this.customFetch,
24
- });
25
- return (0, validators_1.validateProject)(response.data);
26
- }
27
- async getProjects(args = {}) {
28
- const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
29
- httpMethod: 'GET',
30
- baseUri: this.syncApiBase,
31
- relativePath: endpoints_1.ENDPOINT_REST_PROJECTS,
32
- apiToken: this.authToken,
33
- customFetch: this.customFetch,
34
- payload: args,
35
- });
36
- return {
37
- results: (0, validators_1.validateProjectArray)(results),
38
- nextCursor,
39
- };
40
- }
41
- async searchProjects(args) {
42
- const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
43
- httpMethod: 'GET',
44
- baseUri: this.syncApiBase,
45
- relativePath: endpoints_1.ENDPOINT_REST_PROJECTS_SEARCH,
46
- apiToken: this.authToken,
47
- customFetch: this.customFetch,
48
- payload: args,
49
- });
50
- return {
51
- results: (0, validators_1.validateProjectArray)(results),
52
- nextCursor,
53
- };
54
- }
55
- async getArchivedProjects(args = {}) {
56
- const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
57
- httpMethod: 'GET',
58
- baseUri: this.syncApiBase,
59
- relativePath: endpoints_1.ENDPOINT_REST_PROJECTS_ARCHIVED,
60
- apiToken: this.authToken,
61
- customFetch: this.customFetch,
62
- payload: args,
63
- });
64
- return {
65
- results: (0, validators_1.validateProjectArray)(results),
66
- nextCursor,
67
- };
68
- }
69
- async addProject(args, requestId) {
70
- const response = await (0, http_client_1.request)({
71
- httpMethod: 'POST',
72
- baseUri: this.syncApiBase,
73
- relativePath: endpoints_1.ENDPOINT_REST_PROJECTS,
74
- apiToken: this.authToken,
75
- customFetch: this.customFetch,
76
- payload: args,
77
- requestId: requestId,
78
- });
79
- return (0, validators_1.validateProject)(response.data);
80
- }
81
- async updateProject(id, args, requestId) {
82
- validators_1.IdSchema.parse(id);
83
- const response = await (0, http_client_1.request)({
84
- httpMethod: 'POST',
85
- baseUri: this.syncApiBase,
86
- relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_PROJECTS, id),
87
- apiToken: this.authToken,
88
- customFetch: this.customFetch,
89
- payload: args,
90
- requestId: requestId,
91
- });
92
- return (0, validators_1.validateProject)(response.data);
93
- }
94
- async deleteProject(id, requestId) {
95
- validators_1.IdSchema.parse(id);
96
- const response = await (0, http_client_1.request)({
97
- httpMethod: 'DELETE',
98
- baseUri: this.syncApiBase,
99
- relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_PROJECTS, id),
100
- apiToken: this.authToken,
101
- customFetch: this.customFetch,
102
- requestId: requestId,
103
- });
104
- return (0, http_client_1.isSuccess)(response);
105
- }
106
- async archiveProject(id, requestId) {
107
- validators_1.IdSchema.parse(id);
108
- const response = await (0, http_client_1.request)({
109
- httpMethod: 'POST',
110
- baseUri: this.syncApiBase,
111
- relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_PROJECTS, id, endpoints_1.PROJECT_ARCHIVE),
112
- apiToken: this.authToken,
113
- customFetch: this.customFetch,
114
- requestId: requestId,
115
- });
116
- return (0, validators_1.validateProject)(response.data);
117
- }
118
- async unarchiveProject(id, requestId) {
119
- validators_1.IdSchema.parse(id);
120
- const response = await (0, http_client_1.request)({
121
- httpMethod: 'POST',
122
- baseUri: this.syncApiBase,
123
- relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_PROJECTS, id, endpoints_1.PROJECT_UNARCHIVE),
124
- apiToken: this.authToken,
125
- customFetch: this.customFetch,
126
- requestId: requestId,
127
- });
128
- return (0, validators_1.validateProject)(response.data);
129
- }
130
- async moveProjectToWorkspace(args, requestId) {
131
- const response = await (0, http_client_1.request)({
132
- httpMethod: 'POST',
133
- baseUri: this.syncApiBase,
134
- relativePath: endpoints_1.ENDPOINT_REST_PROJECTS_MOVE_TO_WORKSPACE,
135
- apiToken: this.authToken,
136
- customFetch: this.customFetch,
137
- payload: args,
138
- requestId: requestId,
139
- });
140
- return (0, validators_1.validateProject)(response.data.project);
141
- }
142
- async moveProjectToPersonal(args, requestId) {
143
- const response = await (0, http_client_1.request)({
144
- httpMethod: 'POST',
145
- baseUri: this.syncApiBase,
146
- relativePath: endpoints_1.ENDPOINT_REST_PROJECTS_MOVE_TO_PERSONAL,
147
- apiToken: this.authToken,
148
- customFetch: this.customFetch,
149
- payload: args,
150
- requestId: requestId,
151
- });
152
- return (0, validators_1.validateProject)(response.data.project);
153
- }
154
- async getArchivedProjectsCount(args = {}) {
155
- const { data } = await (0, http_client_1.request)({
156
- httpMethod: 'GET',
157
- baseUri: this.syncApiBase,
158
- relativePath: endpoints_1.ENDPOINT_REST_PROJECTS_ARCHIVED_COUNT,
159
- apiToken: this.authToken,
160
- customFetch: this.customFetch,
161
- payload: args,
162
- });
163
- return data;
164
- }
165
- async getProjectPermissions() {
166
- const { data } = await (0, http_client_1.request)({
167
- httpMethod: 'GET',
168
- baseUri: this.syncApiBase,
169
- relativePath: endpoints_1.ENDPOINT_REST_PROJECTS_PERMISSIONS,
170
- apiToken: this.authToken,
171
- customFetch: this.customFetch,
172
- });
173
- return data;
174
- }
175
- async getFullProject(id, args = {}) {
176
- validators_1.IdSchema.parse(id);
177
- const { data } = await (0, http_client_1.request)({
178
- httpMethod: 'GET',
179
- baseUri: this.syncApiBase,
180
- relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_PROJECTS, id, endpoints_1.ENDPOINT_REST_PROJECT_FULL),
181
- apiToken: this.authToken,
182
- customFetch: this.customFetch,
183
- payload: args,
184
- });
185
- return {
186
- project: data.project ? (0, validators_1.validateProject)(data.project) : null,
187
- commentsCount: data.commentsCount,
188
- tasks: (0, validators_1.validateTaskArray)(data.tasks),
189
- sections: (0, validators_1.validateSectionArray)(data.sections),
190
- collaborators: (0, validators_1.validateCollaboratorArray)(data.collaborators).map((collaborator) => (0, validators_1.validateUser)({
191
- id: collaborator.id,
192
- email: collaborator.email,
193
- name: collaborator.fullName,
194
- })),
195
- notes: (0, validators_1.validateCommentArray)(data.notes === undefined ? [] : data.notes),
196
- };
197
- }
198
- async joinProject(id, requestId) {
199
- validators_1.IdSchema.parse(id);
200
- const { data } = await (0, http_client_1.request)({
201
- httpMethod: 'POST',
202
- baseUri: this.syncApiBase,
203
- relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_PROJECTS, id, endpoints_1.ENDPOINT_REST_PROJECT_JOIN),
204
- apiToken: this.authToken,
205
- customFetch: this.customFetch,
206
- requestId: requestId,
207
- });
208
- return {
209
- project: (0, validators_1.validateWorkspaceProject)(data.project),
210
- tasks: (0, validators_1.validateTaskArray)(data.tasks),
211
- sections: (0, validators_1.validateSectionArray)(data.sections),
212
- comments: (0, validators_1.validateNoteArray)(data.comments),
213
- collaborators: (0, validators_1.validateCollaboratorArray)(data.collaborators),
214
- collaboratorStates: (0, validators_1.validateCollaboratorStateArray)(data.collaboratorStates),
215
- folder: data.folder ? (0, validators_1.validateFolder)(data.folder) : null,
216
- subprojects: (0, validators_1.validateWorkspaceProjectArray)(data.subprojects),
217
- };
218
- }
219
- async getProjectCollaborators(projectId, args = {}) {
220
- validators_1.IdSchema.parse(projectId);
221
- const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
222
- httpMethod: 'GET',
223
- baseUri: this.syncApiBase,
224
- relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_PROJECTS, projectId, endpoints_1.ENDPOINT_REST_PROJECT_COLLABORATORS),
225
- apiToken: this.authToken,
226
- customFetch: this.customFetch,
227
- payload: args,
228
- });
229
- return {
230
- results: (0, validators_1.validateUserArray)(results),
231
- nextCursor,
232
- };
233
- }
234
- }
235
- exports.ProjectClient = ProjectClient;