@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,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ActivityEventSchema = exports.ActivityEventExtraDataSchema = void 0;
4
- const zod_1 = require("zod");
5
- /**
6
- * Flexible object containing event-specific data.
7
- * Uses z.record to accept any properties for forward compatibility.
8
- */
9
- exports.ActivityEventExtraDataSchema = zod_1.z.record(zod_1.z.string(), zod_1.z.any()).nullable();
10
- /**
11
- * Activity log event schema. Accepts unknown fields for forward compatibility.
12
- */
13
- exports.ActivityEventSchema = zod_1.z
14
- .object({
15
- objectType: zod_1.z.string(),
16
- objectId: zod_1.z.string(),
17
- eventType: zod_1.z.string(),
18
- eventDate: zod_1.z.coerce.date(),
19
- id: zod_1.z
20
- .union([zod_1.z.string(), zod_1.z.number()])
21
- .transform((val) => { var _a; return (_a = val === null || val === void 0 ? void 0 : val.toString()) !== null && _a !== void 0 ? _a : null; })
22
- .nullable(),
23
- parentProjectId: zod_1.z.string().nullable(),
24
- parentItemId: zod_1.z.string().nullable(),
25
- initiatorId: zod_1.z.string().nullable(),
26
- extraData: exports.ActivityEventExtraDataSchema,
27
- })
28
- .catchall(zod_1.z.any());
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./types"), exports);
18
- __exportStar(require("./requests"), exports);
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,254 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UserAuthorizationSchema = exports.UserAuthorizationAppSchema = exports.AppInstallationSchema = exports.InstalledIntegrationSchema = exports.AppWebhookSchema = exports.AppByDistributionTokenSchema = exports.AppByDistributionTokenUiExtensionSchema = exports.AppDistributionTokenSchema = exports.AppTestTokenSchema = exports.AppVerificationTokenSchema = exports.AppSecretsSchema = exports.AppWithUserCountSchema = exports.AppSchema = exports.AppTokenScopesSchema = exports.InstallationTypeSchema = exports.INSTALLATION_TYPES = exports.WebhookVersionSchema = exports.WEBHOOK_VERSIONS = exports.WebhookStatusSchema = exports.WEBHOOK_STATUSES = exports.WebhookEventWireNameSchema = exports.WEBHOOK_EVENT_WIRE_NAMES = exports.WebhookEventSchema = exports.WEBHOOK_EVENTS = exports.AppStatusSchema = exports.APP_STATUSES = void 0;
4
- exports.webhookEventFromWireName = webhookEventFromWireName;
5
- exports.webhookEventToWireName = webhookEventToWireName;
6
- const zod_1 = require("zod");
7
- const common_1 = require("../common");
8
- const types_1 = require("../ui-extensions/types");
9
- /**
10
- * Available statuses for a developer application.
11
- */
12
- exports.APP_STATUSES = ['public'];
13
- exports.AppStatusSchema = zod_1.z.enum(exports.APP_STATUSES);
14
- /**
15
- * Webhook event types that can be subscribed to.
16
- *
17
- * These are the friendly public names the backend uses in webhook payloads.
18
- * The on-the-wire config endpoint uses a different (legacy) form (see
19
- * {@link WEBHOOK_EVENT_WIRE_NAMES}); the SDK converts between the two
20
- * so consumers only ever work with these pretty names.
21
- *
22
- * @see https://developer.todoist.com/sync/v1/#webhooks
23
- */
24
- exports.WEBHOOK_EVENTS = [
25
- 'item:added',
26
- 'item:updated',
27
- 'item:completed',
28
- 'item:uncompleted',
29
- 'item:deleted',
30
- 'note:added',
31
- 'note:updated',
32
- 'note:deleted',
33
- 'project:added',
34
- 'project:updated',
35
- 'project:deleted',
36
- 'project:archived',
37
- 'project:unarchived',
38
- 'section:added',
39
- 'section:updated',
40
- 'section:deleted',
41
- 'section:archived',
42
- 'section:unarchived',
43
- 'label:added',
44
- 'label:updated',
45
- 'label:deleted',
46
- 'filter:added',
47
- 'filter:updated',
48
- 'filter:deleted',
49
- 'reminder:fired',
50
- ];
51
- exports.WebhookEventSchema = zod_1.z.enum(exports.WEBHOOK_EVENTS);
52
- /**
53
- * Raw wire-format webhook event names used by the config endpoint
54
- * (`POST/GET /apps/<id>/webhook`). Exported for completeness — prefer
55
- * {@link WEBHOOK_EVENTS} when working with the SDK.
56
- */
57
- exports.WEBHOOK_EVENT_WIRE_NAMES = [
58
- 'e_item_added',
59
- 'e_item_updated',
60
- 'e_item_completed',
61
- 'e_item_uncompleted',
62
- 'e_item_deleted',
63
- 'e_note_added',
64
- 'e_note_updated',
65
- 'e_note_deleted',
66
- 'e_project_added',
67
- 'e_project_updated',
68
- 'e_project_deleted',
69
- 'e_project_archived',
70
- 'e_project_unarchived',
71
- 'e_section_added',
72
- 'e_section_updated',
73
- 'e_section_deleted',
74
- 'e_section_archived',
75
- 'e_section_unarchived',
76
- 'e_label_added',
77
- 'e_label_updated',
78
- 'e_label_deleted',
79
- 'e_filter_added',
80
- 'e_filter_updated',
81
- 'e_filter_deleted',
82
- 'e_reminder_fired',
83
- ];
84
- exports.WebhookEventWireNameSchema = zod_1.z.enum(exports.WEBHOOK_EVENT_WIRE_NAMES);
85
- /**
86
- * Translates a wire-format event name (`'e_item_added'`) to its pretty form (`'item:added'`).
87
- */
88
- function webhookEventFromWireName(wireName) {
89
- // Strip leading `e_`, replace first `_` with `:`. The resulting string is
90
- // guaranteed to be a `WebhookEvent` by construction of the two const arrays.
91
- return wireName.slice(2).replace('_', ':');
92
- }
93
- /**
94
- * Translates a pretty event name (`'item:added'`) to its wire-format form (`'e_item_added'`).
95
- */
96
- function webhookEventToWireName(event) {
97
- return ('e_' + event.replace(':', '_'));
98
- }
99
- /**
100
- * Available statuses for an app webhook.
101
- */
102
- exports.WEBHOOK_STATUSES = ['active', 'invalid'];
103
- exports.WebhookStatusSchema = zod_1.z.enum(exports.WEBHOOK_STATUSES);
104
- /**
105
- * Supported webhook payload versions. v9 is deprecated and intentionally excluded.
106
- */
107
- exports.WEBHOOK_VERSIONS = ['1'];
108
- exports.WebhookVersionSchema = zod_1.z.enum(exports.WEBHOOK_VERSIONS);
109
- /**
110
- * Available installation types for an app installation.
111
- */
112
- exports.INSTALLATION_TYPES = ['user'];
113
- exports.InstallationTypeSchema = zod_1.z.enum(exports.INSTALLATION_TYPES);
114
- /**
115
- * Transforms a comma-separated scope string into `string[] | null`.
116
- *
117
- * The backend stores `app_token_scopes` as a single comma-separated string
118
- * (e.g. `"data:read,task:add"`). Reads are exposed as `string[]` (rather than
119
- * `Permission[]`) so that newly added backend scopes don't break parsing —
120
- * writes accept `Permission` for autocomplete while still permitting `string`
121
- * (via `UpdateAppArgs`), so a fetched `App.appTokenScopes` can be round-tripped
122
- * back into `updateApp()` without casts.
123
- *
124
- * Preserves `null` on read (backend returns `null` for apps that have had
125
- * their scopes cleared via `updateApp({ appTokenScopes: null })`) so the
126
- * read and write shapes line up and information is not lost.
127
- */
128
- exports.AppTokenScopesSchema = zod_1.z
129
- .string()
130
- .nullable()
131
- .transform((value) => {
132
- if (value === null)
133
- return null;
134
- if (value === '')
135
- return [];
136
- return value.split(',').filter(Boolean);
137
- });
138
- /**
139
- * Schema for a developer application.
140
- * @see https://developer.todoist.com/api/v1/#tag/Apps
141
- */
142
- exports.AppSchema = zod_1.z.object({
143
- id: common_1.StringOrNumberSchema,
144
- clientId: zod_1.z.string(),
145
- status: exports.AppStatusSchema,
146
- displayName: zod_1.z.string(),
147
- userId: common_1.StringOrNumberSchema,
148
- createdAt: zod_1.z.coerce.date(),
149
- serviceUrl: zod_1.z.string().nullable(),
150
- oauthRedirectUri: zod_1.z.string().nullable(),
151
- description: zod_1.z.string().nullable(),
152
- iconSm: zod_1.z.string().nullable(),
153
- iconMd: zod_1.z.string().nullable(),
154
- iconLg: zod_1.z.string().nullable(),
155
- appTokenScopes: exports.AppTokenScopesSchema,
156
- });
157
- /**
158
- * Schema for a developer application that includes the user count.
159
- * Returned by most endpoints that manage a single app (get, update, delete).
160
- */
161
- exports.AppWithUserCountSchema = exports.AppSchema.extend({
162
- userCount: zod_1.z.number().int(),
163
- });
164
- /**
165
- * OAuth client credentials for a developer application.
166
- */
167
- exports.AppSecretsSchema = zod_1.z.object({
168
- clientId: zod_1.z.string(),
169
- clientSecret: zod_1.z.string(),
170
- });
171
- /**
172
- * Webhook verification token for a developer application.
173
- */
174
- exports.AppVerificationTokenSchema = zod_1.z.object({
175
- verificationToken: zod_1.z.string(),
176
- });
177
- /**
178
- * Developer test access token for a developer application.
179
- */
180
- exports.AppTestTokenSchema = zod_1.z.object({
181
- accessToken: zod_1.z.string().nullish(),
182
- });
183
- /**
184
- * Distribution token for a developer application.
185
- */
186
- exports.AppDistributionTokenSchema = zod_1.z.object({
187
- distributionToken: zod_1.z.string(),
188
- });
189
- /**
190
- * Subset of an app returned when resolving by distribution token — used by the installation flow.
191
- * Includes a lightweight list of the app's UI extensions (not full `UIExtension` records).
192
- */
193
- exports.AppByDistributionTokenUiExtensionSchema = zod_1.z.object({
194
- name: zod_1.z.string(),
195
- description: zod_1.z.string(),
196
- icon: zod_1.z.string().nullable(),
197
- extensionType: zod_1.z.enum(types_1.UI_EXTENSION_TYPES),
198
- });
199
- exports.AppByDistributionTokenSchema = zod_1.z.object({
200
- id: common_1.StringOrNumberSchema,
201
- displayName: zod_1.z.string(),
202
- description: zod_1.z.string().nullable(),
203
- iconMd: zod_1.z.string().nullable(),
204
- appTokenScopes: exports.AppTokenScopesSchema,
205
- uiExtensions: zod_1.z.array(exports.AppByDistributionTokenUiExtensionSchema),
206
- });
207
- /**
208
- * Schema for an app webhook.
209
- *
210
- * Events arrive from the wire in their `e_*` form and are transformed to
211
- * their pretty `item:added`-style names for SDK consumers.
212
- */
213
- exports.AppWebhookSchema = zod_1.z.object({
214
- status: exports.WebhookStatusSchema,
215
- callbackUrl: zod_1.z.string(),
216
- version: exports.WebhookVersionSchema,
217
- events: zod_1.z.array(exports.WebhookEventWireNameSchema.transform(webhookEventFromWireName)),
218
- });
219
- /**
220
- * Lightweight view of an app embedded in an installation record.
221
- * Mirrors `AppSchema` shape — backend returns the same `ApplicationRestView`.
222
- */
223
- exports.InstalledIntegrationSchema = exports.AppSchema;
224
- /**
225
- * Schema for an installed application (integration installed to a user's account).
226
- */
227
- exports.AppInstallationSchema = zod_1.z.object({
228
- id: common_1.StringOrNumberSchema,
229
- creator: common_1.StringOrNumberSchema,
230
- createdTs: zod_1.z.number().int(),
231
- installationType: exports.InstallationTypeSchema,
232
- appTokenScopesValidated: zod_1.z.boolean(),
233
- integration: exports.InstalledIntegrationSchema.nullable(),
234
- });
235
- /**
236
- * Lightweight app info included on a user authorization record.
237
- */
238
- exports.UserAuthorizationAppSchema = zod_1.z.object({
239
- id: common_1.StringOrNumberSchema,
240
- displayName: zod_1.z.string(),
241
- description: zod_1.z.string().nullable(),
242
- serviceUrl: zod_1.z.string().nullable(),
243
- iconMd: zod_1.z.string().nullable(),
244
- });
245
- /**
246
- * Schema for a user authorization entry — a token the user has granted to a third-party app.
247
- */
248
- exports.UserAuthorizationSchema = zod_1.z.object({
249
- accessTokenId: common_1.StringOrNumberSchema,
250
- scope: zod_1.z.array(zod_1.z.string()),
251
- scopeDescriptions: zod_1.z.array(zod_1.z.string()),
252
- createdAt: zod_1.z.coerce.date(),
253
- app: exports.UserAuthorizationAppSchema.nullable(),
254
- });
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./types"), exports);
18
- __exportStar(require("./requests"), exports);
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BackupSchema = void 0;
4
- const zod_1 = require("zod");
5
- exports.BackupSchema = zod_1.z.object({
6
- version: zod_1.z.string(),
7
- url: zod_1.z.string(),
8
- });
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./types"), exports);
18
- __exportStar(require("./requests"), exports);
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,92 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PricingResponseSchema = exports.PricingVersionSchema = exports.PricingTermsSchema = exports.PricesResponseSchema = exports.ProPlanDetailsSchema = exports.PriceListingSchema = exports.FormattedPriceSchema = exports.SubscriptionInfoSchema = exports.BillingPlanPriceSchema = exports.TAX_BEHAVIORS = exports.BILLING_CYCLES = exports.BILLING_ACTIVATION_METHODS = exports.BILLING_PLANS = exports.BILLING_SUBSCRIPTION_STATUSES = void 0;
4
- const zod_1 = require("zod");
5
- const types_1 = require("../workspaces/types");
6
- /** Available subscription statuses. */
7
- exports.BILLING_SUBSCRIPTION_STATUSES = [
8
- 'none',
9
- 'autorenew',
10
- 'canceled',
11
- 'expired',
12
- 'trial',
13
- 'trial_canceled',
14
- ];
15
- /** Available plan tiers. */
16
- exports.BILLING_PLANS = ['free', 'pro', 'pro_gifted', 'pro_legacy'];
17
- /** Ways an active subscription can be purchased. */
18
- exports.BILLING_ACTIVATION_METHODS = [
19
- 'stripe',
20
- 'appstore',
21
- 'playstore',
22
- 'teams',
23
- 'manual',
24
- ];
25
- /** Available billing cycles. */
26
- exports.BILLING_CYCLES = ['monthly', 'yearly'];
27
- /** Available tax behaviors for a price. */
28
- exports.TAX_BEHAVIORS = ['exclusive', 'inclusive', 'unspecified'];
29
- exports.BillingPlanPriceSchema = zod_1.z.object({
30
- amount: zod_1.z.string(),
31
- rawAmount: zod_1.z.number(),
32
- currency: zod_1.z.string(),
33
- billingCycle: zod_1.z.enum(exports.BILLING_CYCLES).nullable(),
34
- taxBehavior: zod_1.z.enum(exports.TAX_BEHAVIORS),
35
- });
36
- exports.SubscriptionInfoSchema = zod_1.z.object({
37
- status: zod_1.z.enum(exports.BILLING_SUBSCRIPTION_STATUSES),
38
- plan: zod_1.z.enum(exports.BILLING_PLANS),
39
- expirationDate: zod_1.z.string().nullable(),
40
- activationMethod: zod_1.z.enum(exports.BILLING_ACTIVATION_METHODS),
41
- planPrice: exports.BillingPlanPriceSchema.nullable(),
42
- billingPortalUrl: zod_1.z.string().nullable(),
43
- billingPortalSwitchToAnnualUrl: zod_1.z.string().nullable(),
44
- hasBillingPortal: zod_1.z.boolean(),
45
- hasBillingPortalSwitchToAnnual: zod_1.z.boolean(),
46
- invoiceCreditBalance: zod_1.z.record(zod_1.z.string(), zod_1.z.number().int()).nullable(),
47
- hasSwitchLegacyToCurrent: zod_1.z.boolean(),
48
- });
49
- exports.FormattedPriceSchema = zod_1.z.object({
50
- currency: zod_1.z.string(),
51
- unitAmount: zod_1.z.number().int(),
52
- taxBehavior: zod_1.z.enum(exports.TAX_BEHAVIORS),
53
- });
54
- exports.PriceListingSchema = zod_1.z.object({
55
- billingCycle: zod_1.z.enum(exports.BILLING_CYCLES),
56
- prices: zod_1.z.array(exports.FormattedPriceSchema),
57
- });
58
- exports.ProPlanDetailsSchema = zod_1.z.object({
59
- currentPlanStatus: zod_1.z.enum(types_1.WORKSPACE_PLAN_STATUSES),
60
- downgradeAt: zod_1.z.string().nullable(),
61
- priceList: zod_1.z.array(exports.PriceListingSchema),
62
- });
63
- exports.PricesResponseSchema = zod_1.z.object({
64
- pro: zod_1.z.array(exports.PriceListingSchema),
65
- teams: zod_1.z.array(exports.PriceListingSchema),
66
- });
67
- /**
68
- * Monthly and yearly amounts for a single currency. Each amount is a number in
69
- * the currency's smallest unit, or a localized formatted string when the
70
- * `pricing` endpoint is called with `formatted: true`.
71
- */
72
- exports.PricingTermsSchema = zod_1.z.object({
73
- monthly: zod_1.z.union([zod_1.z.number(), zod_1.z.string()]),
74
- yearly: zod_1.z.union([zod_1.z.number(), zod_1.z.string()]),
75
- });
76
- /**
77
- * A pricing version entry: plan name (`pro` / `biz`) → currency code →
78
- * {@link PricingTerms}.
79
- */
80
- exports.PricingVersionSchema = zod_1.z.record(zod_1.z.string(), zod_1.z.record(zod_1.z.string(), exports.PricingTermsSchema));
81
- /**
82
- * Response of the `pricing` endpoint: fixed version-pointer string fields plus
83
- * dynamic version keys (`v1`, `v2`, …), each a {@link PricingVersion}.
84
- */
85
- exports.PricingResponseSchema = zod_1.z
86
- .object({
87
- latestPro: zod_1.z.string(),
88
- latestBiz: zod_1.z.string(),
89
- sessionPro: zod_1.z.string(),
90
- sessionBiz: zod_1.z.string(),
91
- })
92
- .catchall(exports.PricingVersionSchema);
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./types"), exports);
18
- __exportStar(require("./requests"), exports);
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,60 +0,0 @@
1
- "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.CommentSchema = exports.RawCommentSchema = exports.AttachmentSchema = exports.UPLOAD_STATES = void 0;
15
- const zod_1 = require("zod");
16
- /** Available file attachment upload states. */
17
- exports.UPLOAD_STATES = ['pending', 'completed'];
18
- exports.AttachmentSchema = zod_1.z
19
- .object({
20
- resourceType: zod_1.z.string(),
21
- })
22
- .extend({
23
- fileName: zod_1.z.string().nullable().optional(),
24
- fileSize: zod_1.z.number().int().nullable().optional(),
25
- fileType: zod_1.z.string().nullable().optional(),
26
- fileUrl: zod_1.z.string().nullable().optional(),
27
- fileDuration: zod_1.z.number().int().nullable().optional(),
28
- uploadState: zod_1.z.enum(exports.UPLOAD_STATES).nullable().optional(),
29
- image: zod_1.z.string().nullable().optional(),
30
- imageWidth: zod_1.z.number().int().nullable().optional(),
31
- imageHeight: zod_1.z.number().int().nullable().optional(),
32
- url: zod_1.z.string().nullable().optional(),
33
- title: zod_1.z.string().nullable().optional(),
34
- });
35
- exports.RawCommentSchema = zod_1.z
36
- .object({
37
- id: zod_1.z.string(),
38
- itemId: zod_1.z.string().optional(),
39
- projectId: zod_1.z.string().optional(),
40
- content: zod_1.z.string(),
41
- postedAt: zod_1.z.coerce.date(),
42
- fileAttachment: exports.AttachmentSchema.nullable(),
43
- postedUid: zod_1.z.string(),
44
- uidsToNotify: zod_1.z.array(zod_1.z.string()).nullable(),
45
- reactions: zod_1.z.record(zod_1.z.string(), zod_1.z.array(zod_1.z.string())).nullable(),
46
- isDeleted: zod_1.z.boolean(),
47
- })
48
- .refine((data) => {
49
- // At least one of itemId or projectId must be present
50
- return ((data.itemId !== undefined && data.projectId === undefined) ||
51
- (data.itemId === undefined && data.projectId !== undefined));
52
- }, {
53
- message: 'Exactly one of itemId or projectId must be provided',
54
- });
55
- exports.CommentSchema = exports.RawCommentSchema.transform((data) => {
56
- const { itemId } = data, rest = __rest(data, ["itemId"]);
57
- return Object.assign(Object.assign({}, rest), {
58
- // Map itemId to taskId for backwards compatibility
59
- taskId: itemId });
60
- });
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StringOrNumberSchema = void 0;
4
- const zod_1 = require("zod");
5
- /**
6
- * Zod schema that accepts both string and number values and coerces to string.
7
- * The REST API returns numeric IDs while the Sync API returns string IDs.
8
- */
9
- const StringOrNumberSchema = zod_1.z.union([zod_1.z.string(), zod_1.z.number()]).transform((val) => String(val));
10
- exports.StringOrNumberSchema = StringOrNumberSchema;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./requests"), exports);
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EMAIL_OBJECT_TYPES = void 0;
4
- /** Object types that support email forwarding. */
5
- exports.EMAIL_OBJECT_TYPES = ['project', 'project_comments', 'task'];
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TodoistArgumentError = exports.TodoistRequestError = void 0;
4
- const ts_custom_error_1 = require("ts-custom-error");
5
- const authenticationErrorCodes = [401, 403];
6
- class TodoistRequestError extends ts_custom_error_1.CustomError {
7
- constructor(message, httpStatusCode, responseData) {
8
- super(message);
9
- this.message = message;
10
- this.httpStatusCode = httpStatusCode;
11
- this.responseData = responseData;
12
- this.isAuthenticationError = () => {
13
- if (!this.httpStatusCode) {
14
- return false;
15
- }
16
- return authenticationErrorCodes.includes(this.httpStatusCode);
17
- };
18
- Object.defineProperty(this, 'name', { value: 'TodoistRequestError' });
19
- }
20
- }
21
- exports.TodoistRequestError = TodoistRequestError;
22
- class TodoistArgumentError extends ts_custom_error_1.CustomError {
23
- constructor(message) {
24
- super(message);
25
- this.message = message;
26
- Object.defineProperty(this, 'name', { value: 'TodoistArgumentError' });
27
- }
28
- }
29
- exports.TodoistArgumentError = TodoistArgumentError;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./requests"), exports);
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isNetworkError = isNetworkError;
4
- exports.isHttpError = isHttpError;
5
- /**
6
- * Type guard to check if an error is a network error
7
- */
8
- function isNetworkError(error) {
9
- // Network errors in fetch are typically TypeError with specific messages.
10
- // Timeout errors are created by fetch-with-retry with the TimeoutError name.
11
- return ((error instanceof TypeError &&
12
- (error.message.includes('fetch') ||
13
- error.message.includes('network') ||
14
- error.message.includes('Failed to fetch') ||
15
- error.message.includes('NetworkError'))) ||
16
- error.name === 'TimeoutError' ||
17
- error.isNetworkError === true);
18
- }
19
- /**
20
- * Type guard to check if an error is an HTTP error
21
- */
22
- function isHttpError(error) {
23
- return 'status' in error && typeof error.status === 'number';
24
- }