@doist/todoist-sdk 14.1.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 (172) hide show
  1. package/README.md +46 -1
  2. package/dist/esm/index.js +1 -1
  3. package/dist/esm/transport/http-dispatcher.js +25 -0
  4. package/dist/esm/utils/index.js +1 -1
  5. package/dist/esm/utils/multipart-upload.js +171 -57
  6. package/dist/esm/utils/url-helpers.js +151 -23
  7. package/dist/types/index.d.ts +2 -1
  8. package/dist/types/transport/http-dispatcher.d.ts +26 -1
  9. package/dist/types/utils/index.d.ts +2 -1
  10. package/dist/types/utils/url-helpers.d.ts +88 -0
  11. package/package.json +6 -12
  12. package/dist/cjs/authentication.js +0 -317
  13. package/dist/cjs/clients/activity-client.js +0 -63
  14. package/dist/cjs/clients/app-client.js +0 -345
  15. package/dist/cjs/clients/backup-client.js +0 -47
  16. package/dist/cjs/clients/base-client.js +0 -31
  17. package/dist/cjs/clients/billing-client.js +0 -152
  18. package/dist/cjs/clients/comment-client.js +0 -91
  19. package/dist/cjs/clients/email-client.js +0 -43
  20. package/dist/cjs/clients/folder-client.js +0 -79
  21. package/dist/cjs/clients/id-mapping-client.js +0 -39
  22. package/dist/cjs/clients/insights-client.js +0 -87
  23. package/dist/cjs/clients/label-client.js +0 -126
  24. package/dist/cjs/clients/productivity-client.js +0 -27
  25. package/dist/cjs/clients/project-client.js +0 -235
  26. package/dist/cjs/clients/reminder-client.js +0 -198
  27. package/dist/cjs/clients/section-client.js +0 -117
  28. package/dist/cjs/clients/task-client.js +0 -254
  29. package/dist/cjs/clients/template-client.js +0 -88
  30. package/dist/cjs/clients/ui-extension-client.js +0 -107
  31. package/dist/cjs/clients/upload-client.js +0 -155
  32. package/dist/cjs/clients/view-options-client.js +0 -25
  33. package/dist/cjs/clients/workspace-client.js +0 -366
  34. package/dist/cjs/consts/endpoints.js +0 -224
  35. package/dist/cjs/index.js +0 -23
  36. package/dist/cjs/package.json +0 -1
  37. package/dist/cjs/test-utils/asserts.js +0 -11
  38. package/dist/cjs/test-utils/msw-setup.js +0 -97
  39. package/dist/cjs/test-utils/obsidian-fetch-adapter.js +0 -54
  40. package/dist/cjs/test-utils/test-defaults.js +0 -371
  41. package/dist/cjs/test-utils/transport-seam.js +0 -17
  42. package/dist/cjs/test-utils/webhook-fixtures.js +0 -32
  43. package/dist/cjs/todoist-api.js +0 -1711
  44. package/dist/cjs/transport/fetch-with-retry.js +0 -219
  45. package/dist/cjs/transport/http-client.js +0 -134
  46. package/dist/cjs/transport/http-dispatcher.js +0 -173
  47. package/dist/cjs/transport/sync-request.js +0 -83
  48. package/dist/cjs/types/activity/index.js +0 -18
  49. package/dist/cjs/types/activity/requests.js +0 -2
  50. package/dist/cjs/types/activity/types.js +0 -28
  51. package/dist/cjs/types/apps/index.js +0 -18
  52. package/dist/cjs/types/apps/requests.js +0 -2
  53. package/dist/cjs/types/apps/types.js +0 -254
  54. package/dist/cjs/types/backups/index.js +0 -18
  55. package/dist/cjs/types/backups/requests.js +0 -2
  56. package/dist/cjs/types/backups/types.js +0 -8
  57. package/dist/cjs/types/billing/index.js +0 -18
  58. package/dist/cjs/types/billing/requests.js +0 -2
  59. package/dist/cjs/types/billing/types.js +0 -92
  60. package/dist/cjs/types/comments/index.js +0 -18
  61. package/dist/cjs/types/comments/requests.js +0 -2
  62. package/dist/cjs/types/comments/types.js +0 -60
  63. package/dist/cjs/types/common.js +0 -10
  64. package/dist/cjs/types/emails/index.js +0 -17
  65. package/dist/cjs/types/emails/requests.js +0 -5
  66. package/dist/cjs/types/errors.js +0 -29
  67. package/dist/cjs/types/folders/index.js +0 -17
  68. package/dist/cjs/types/folders/requests.js +0 -2
  69. package/dist/cjs/types/http.js +0 -24
  70. package/dist/cjs/types/id-mappings/index.js +0 -18
  71. package/dist/cjs/types/id-mappings/requests.js +0 -20
  72. package/dist/cjs/types/id-mappings/types.js +0 -12
  73. package/dist/cjs/types/index.js +0 -40
  74. package/dist/cjs/types/insights/index.js +0 -18
  75. package/dist/cjs/types/insights/requests.js +0 -2
  76. package/dist/cjs/types/insights/types.js +0 -80
  77. package/dist/cjs/types/labels/index.js +0 -18
  78. package/dist/cjs/types/labels/requests.js +0 -2
  79. package/dist/cjs/types/labels/types.js +0 -11
  80. package/dist/cjs/types/productivity/index.js +0 -17
  81. package/dist/cjs/types/productivity/types.js +0 -68
  82. package/dist/cjs/types/projects/index.js +0 -18
  83. package/dist/cjs/types/projects/requests.js +0 -2
  84. package/dist/cjs/types/projects/types.js +0 -66
  85. package/dist/cjs/types/reminders/index.js +0 -17
  86. package/dist/cjs/types/reminders/requests.js +0 -95
  87. package/dist/cjs/types/sections/index.js +0 -18
  88. package/dist/cjs/types/sections/requests.js +0 -2
  89. package/dist/cjs/types/sections/types.js +0 -25
  90. package/dist/cjs/types/sync/commands/calendars.js +0 -2
  91. package/dist/cjs/types/sync/commands/filters.js +0 -2
  92. package/dist/cjs/types/sync/commands/folders.js +0 -2
  93. package/dist/cjs/types/sync/commands/index.js +0 -34
  94. package/dist/cjs/types/sync/commands/labels.js +0 -5
  95. package/dist/cjs/types/sync/commands/notes.js +0 -2
  96. package/dist/cjs/types/sync/commands/notifications.js +0 -2
  97. package/dist/cjs/types/sync/commands/others.js +0 -2
  98. package/dist/cjs/types/sync/commands/project-view-options.js +0 -2
  99. package/dist/cjs/types/sync/commands/projects.js +0 -2
  100. package/dist/cjs/types/sync/commands/reminders.js +0 -2
  101. package/dist/cjs/types/sync/commands/sections.js +0 -2
  102. package/dist/cjs/types/sync/commands/shared.js +0 -20
  103. package/dist/cjs/types/sync/commands/sharing.js +0 -2
  104. package/dist/cjs/types/sync/commands/tasks.js +0 -2
  105. package/dist/cjs/types/sync/commands/view-options.js +0 -2
  106. package/dist/cjs/types/sync/commands/workspace-filters.js +0 -2
  107. package/dist/cjs/types/sync/commands/workspaces.js +0 -2
  108. package/dist/cjs/types/sync/index.js +0 -22
  109. package/dist/cjs/types/sync/request.js +0 -2
  110. package/dist/cjs/types/sync/resource-types.js +0 -39
  111. package/dist/cjs/types/sync/resources/calendars.js +0 -27
  112. package/dist/cjs/types/sync/resources/collaborators.js +0 -21
  113. package/dist/cjs/types/sync/resources/completed-info.js +0 -24
  114. package/dist/cjs/types/sync/resources/filters.js +0 -14
  115. package/dist/cjs/types/sync/resources/folders.js +0 -12
  116. package/dist/cjs/types/sync/resources/index.js +0 -32
  117. package/dist/cjs/types/sync/resources/live-notifications.js +0 -38
  118. package/dist/cjs/types/sync/resources/notes.js +0 -21
  119. package/dist/cjs/types/sync/resources/reminders.js +0 -50
  120. package/dist/cjs/types/sync/resources/suggestions.js +0 -36
  121. package/dist/cjs/types/sync/resources/tooltips.js +0 -8
  122. package/dist/cjs/types/sync/resources/user-plan-limits.js +0 -20
  123. package/dist/cjs/types/sync/resources/user-settings.js +0 -40
  124. package/dist/cjs/types/sync/resources/user.js +0 -110
  125. package/dist/cjs/types/sync/resources/view-options.js +0 -86
  126. package/dist/cjs/types/sync/resources/workspace-filters.js +0 -19
  127. package/dist/cjs/types/sync/resources/workspaces.js +0 -72
  128. package/dist/cjs/types/sync/response.js +0 -54
  129. package/dist/cjs/types/sync/user-preferences.js +0 -71
  130. package/dist/cjs/types/tasks/index.js +0 -18
  131. package/dist/cjs/types/tasks/requests.js +0 -2
  132. package/dist/cjs/types/tasks/types.js +0 -59
  133. package/dist/cjs/types/templates/index.js +0 -17
  134. package/dist/cjs/types/templates/requests.js +0 -2
  135. package/dist/cjs/types/ui-extensions/index.js +0 -18
  136. package/dist/cjs/types/ui-extensions/requests.js +0 -2
  137. package/dist/cjs/types/ui-extensions/types.js +0 -77
  138. package/dist/cjs/types/uploads/index.js +0 -17
  139. package/dist/cjs/types/uploads/requests.js +0 -2
  140. package/dist/cjs/types/users/index.js +0 -17
  141. package/dist/cjs/types/users/types.js +0 -51
  142. package/dist/cjs/types/webhooks/comments.js +0 -96
  143. package/dist/cjs/types/webhooks/envelope.js +0 -26
  144. package/dist/cjs/types/webhooks/filters.js +0 -30
  145. package/dist/cjs/types/webhooks/index.js +0 -25
  146. package/dist/cjs/types/webhooks/labels.js +0 -54
  147. package/dist/cjs/types/webhooks/projects.js +0 -36
  148. package/dist/cjs/types/webhooks/reminders.js +0 -35
  149. package/dist/cjs/types/webhooks/sections.js +0 -53
  150. package/dist/cjs/types/webhooks/tasks.js +0 -68
  151. package/dist/cjs/types/webhooks/types.js +0 -55
  152. package/dist/cjs/types/workspaces/index.js +0 -18
  153. package/dist/cjs/types/workspaces/requests.js +0 -2
  154. package/dist/cjs/types/workspaces/types.js +0 -154
  155. package/dist/cjs/utils/activity-helpers.js +0 -58
  156. package/dist/cjs/utils/case-conversion.js +0 -69
  157. package/dist/cjs/utils/colors.js +0 -143
  158. package/dist/cjs/utils/file-response.js +0 -32
  159. package/dist/cjs/utils/headers.js +0 -16
  160. package/dist/cjs/utils/index.js +0 -31
  161. package/dist/cjs/utils/multipart-upload.js +0 -179
  162. package/dist/cjs/utils/processing-helpers.js +0 -18
  163. package/dist/cjs/utils/project-helpers.js +0 -20
  164. package/dist/cjs/utils/request-helpers.js +0 -21
  165. package/dist/cjs/utils/sanitization.js +0 -116
  166. package/dist/cjs/utils/sync-helpers.js +0 -22
  167. package/dist/cjs/utils/task-sorting.js +0 -281
  168. package/dist/cjs/utils/uncompletable-helpers.js +0 -60
  169. package/dist/cjs/utils/url-helpers.js +0 -74
  170. package/dist/cjs/utils/validators.js +0 -108
  171. package/dist/cjs/utils/view-options.js +0 -19
  172. package/dist/cjs/utils/webhook-parser.js +0 -60
@@ -1,25 +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("./comments"), exports);
18
- __exportStar(require("./envelope"), exports);
19
- __exportStar(require("./filters"), exports);
20
- __exportStar(require("./labels"), exports);
21
- __exportStar(require("./projects"), exports);
22
- __exportStar(require("./reminders"), exports);
23
- __exportStar(require("./sections"), exports);
24
- __exportStar(require("./tasks"), exports);
25
- __exportStar(require("./types"), exports);
@@ -1,54 +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.LabelDeletedPayloadSchema = exports.LabelUpdatedPayloadSchema = exports.LabelAddedPayloadSchema = exports.WebhookLabelSchema = exports.LABEL_WEBHOOK_EVENTS = exports.LabelWebhookEventEnum = void 0;
15
- const zod_1 = require("zod");
16
- const types_1 = require("../labels/types");
17
- const envelope_1 = require("./envelope");
18
- /**
19
- * Enum-like object of label (`label:*`) webhook event names. Single source
20
- * of truth for the discriminator values — `LABEL_WEBHOOK_EVENTS` and every
21
- * `z.literal()` below derive from it.
22
- */
23
- exports.LabelWebhookEventEnum = {
24
- Added: 'label:added',
25
- Updated: 'label:updated',
26
- Deleted: 'label:deleted',
27
- };
28
- /** Webhook events that carry a label as their `eventData`. */
29
- exports.LABEL_WEBHOOK_EVENTS = [
30
- exports.LabelWebhookEventEnum.Added,
31
- exports.LabelWebhookEventEnum.Updated,
32
- exports.LabelWebhookEventEnum.Deleted,
33
- ];
34
- /**
35
- * A label as delivered in a webhook payload.
36
- *
37
- * Webhook label payloads differ from the REST label shape in two ways:
38
- * they use `item_order` (not `order`) and always include `is_deleted`. This
39
- * schema reuses {@link LabelSchema}, swapping `order` for `itemOrder` on
40
- * the input side and renaming it back after validation, and surfaces
41
- * `isDeleted` for downstream filtering.
42
- */
43
- exports.WebhookLabelSchema = types_1.LabelSchema.omit({ order: true })
44
- .extend({
45
- itemOrder: zod_1.z.number().int().nullable(),
46
- isDeleted: zod_1.z.boolean(),
47
- })
48
- .transform((_a) => {
49
- var { itemOrder } = _a, rest = __rest(_a, ["itemOrder"]);
50
- return (Object.assign(Object.assign({}, rest), { order: itemOrder }));
51
- });
52
- exports.LabelAddedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.LabelWebhookEventEnum.Added), eventData: exports.WebhookLabelSchema }));
53
- exports.LabelUpdatedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.LabelWebhookEventEnum.Updated), eventData: exports.WebhookLabelSchema }));
54
- exports.LabelDeletedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.LabelWebhookEventEnum.Deleted), eventData: exports.WebhookLabelSchema }));
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ProjectUnarchivedPayloadSchema = exports.ProjectArchivedPayloadSchema = exports.ProjectDeletedPayloadSchema = exports.ProjectUpdatedPayloadSchema = exports.ProjectAddedPayloadSchema = exports.PROJECT_WEBHOOK_EVENTS = exports.ProjectWebhookEventEnum = void 0;
4
- const zod_1 = require("zod");
5
- const types_1 = require("../projects/types");
6
- const envelope_1 = require("./envelope");
7
- /**
8
- * Enum-like object of project (`project:*`) webhook event names. Single
9
- * source of truth for the discriminator values — `PROJECT_WEBHOOK_EVENTS`
10
- * and every `z.literal()` below derive from it.
11
- */
12
- exports.ProjectWebhookEventEnum = {
13
- Added: 'project:added',
14
- Updated: 'project:updated',
15
- Deleted: 'project:deleted',
16
- Archived: 'project:archived',
17
- Unarchived: 'project:unarchived',
18
- };
19
- /** Webhook events that carry a project as their `eventData`. */
20
- exports.PROJECT_WEBHOOK_EVENTS = [
21
- exports.ProjectWebhookEventEnum.Added,
22
- exports.ProjectWebhookEventEnum.Updated,
23
- exports.ProjectWebhookEventEnum.Deleted,
24
- exports.ProjectWebhookEventEnum.Archived,
25
- exports.ProjectWebhookEventEnum.Unarchived,
26
- ];
27
- /**
28
- * Webhook project payloads match the shape of the shared {@link Project}
29
- * resource — either a personal or a workspace project. No webhook-specific
30
- * schema is needed; `ProjectSchema` already dispatches on `workspaceId`.
31
- */
32
- exports.ProjectAddedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.ProjectWebhookEventEnum.Added), eventData: types_1.ProjectSchema }));
33
- exports.ProjectUpdatedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.ProjectWebhookEventEnum.Updated), eventData: types_1.ProjectSchema }));
34
- exports.ProjectDeletedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.ProjectWebhookEventEnum.Deleted), eventData: types_1.ProjectSchema }));
35
- exports.ProjectArchivedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.ProjectWebhookEventEnum.Archived), eventData: types_1.ProjectSchema }));
36
- exports.ProjectUnarchivedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.ProjectWebhookEventEnum.Unarchived), eventData: types_1.ProjectSchema }));
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ReminderFiredPayloadSchema = exports.WebhookFiredReminderSchema = exports.REMINDER_WEBHOOK_EVENTS = exports.ReminderWebhookEventEnum = void 0;
4
- const zod_1 = require("zod");
5
- const reminders_1 = require("../sync/resources/reminders");
6
- const types_1 = require("../tasks/types");
7
- const envelope_1 = require("./envelope");
8
- /**
9
- * Enum-like object of reminder (`reminder:*`) webhook event names. Single
10
- * source of truth for the discriminator values — `REMINDER_WEBHOOK_EVENTS`
11
- * and every `z.literal()` below derive from it.
12
- */
13
- exports.ReminderWebhookEventEnum = {
14
- Fired: 'reminder:fired',
15
- };
16
- /** Webhook events that carry a fired-reminder as their `eventData`. */
17
- exports.REMINDER_WEBHOOK_EVENTS = [
18
- exports.ReminderWebhookEventEnum.Fired,
19
- ];
20
- /**
21
- * A fired-reminder notification as delivered in a webhook payload.
22
- *
23
- * `reminder:fired` carries a subset of the full Reminder record (closer
24
- * to a fired-notification projection), so it doesn't line up with any of
25
- * the {@link Reminder} discriminated variants directly. This schema
26
- * reuses {@link ReminderBaseSchema} for the common identity fields and
27
- * adds the fields always present on a fired notification.
28
- */
29
- exports.WebhookFiredReminderSchema = reminders_1.ReminderBaseSchema.extend({
30
- type: zod_1.z.enum(reminders_1.REMINDER_TYPES),
31
- isUrgent: zod_1.z.boolean(),
32
- minuteOffset: zod_1.z.number().int().nullable(),
33
- due: types_1.DueDateSchema.nullable(),
34
- });
35
- exports.ReminderFiredPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.ReminderWebhookEventEnum.Fired), eventData: exports.WebhookFiredReminderSchema }));
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SectionUnarchivedPayloadSchema = exports.SectionArchivedPayloadSchema = exports.SectionDeletedPayloadSchema = exports.SectionUpdatedPayloadSchema = exports.SectionAddedPayloadSchema = exports.WebhookSectionSchema = exports.SECTION_WEBHOOK_EVENTS = exports.SectionWebhookEventEnum = void 0;
4
- const zod_1 = require("zod");
5
- const url_helpers_1 = require("../../utils/url-helpers");
6
- const types_1 = require("../sections/types");
7
- const envelope_1 = require("./envelope");
8
- /**
9
- * Enum-like object of section (`section:*`) webhook event names. Single
10
- * source of truth for the discriminator values — `SECTION_WEBHOOK_EVENTS`
11
- * and every `z.literal()` below derive from it.
12
- */
13
- exports.SectionWebhookEventEnum = {
14
- Added: 'section:added',
15
- Updated: 'section:updated',
16
- Deleted: 'section:deleted',
17
- Archived: 'section:archived',
18
- Unarchived: 'section:unarchived',
19
- };
20
- /** Webhook events that carry a section as their `eventData`. */
21
- exports.SECTION_WEBHOOK_EVENTS = [
22
- exports.SectionWebhookEventEnum.Added,
23
- exports.SectionWebhookEventEnum.Updated,
24
- exports.SectionWebhookEventEnum.Deleted,
25
- exports.SectionWebhookEventEnum.Archived,
26
- exports.SectionWebhookEventEnum.Unarchived,
27
- ];
28
- /**
29
- * A section as delivered in a webhook payload.
30
- *
31
- * Reuses {@link SectionBaseSchema} and overrides `updatedAt` to tolerate
32
- * payloads that deliver it as `null` or omit the key entirely — tombstones
33
- * and never-updated sections come through without an `updated_at` value.
34
- * The result is normalised to `Date | null` so consumers don't have to
35
- * handle three shapes. `description` is similarly tolerated (older webhook
36
- * payloads may omit it) and normalised to `string | null`. Surfaces the
37
- * computed `url` so the exposed shape matches {@link Section}.
38
- */
39
- exports.WebhookSectionSchema = types_1.SectionBaseSchema.extend({
40
- updatedAt: zod_1.z.coerce
41
- .date()
42
- .nullish()
43
- .transform((value) => value !== null && value !== void 0 ? value : null),
44
- description: zod_1.z
45
- .string()
46
- .nullish()
47
- .transform((value) => value !== null && value !== void 0 ? value : null),
48
- }).transform((data) => (Object.assign(Object.assign({}, data), { url: (0, url_helpers_1.getSectionUrl)(data.id, data.name) })));
49
- exports.SectionAddedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.SectionWebhookEventEnum.Added), eventData: exports.WebhookSectionSchema }));
50
- exports.SectionUpdatedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.SectionWebhookEventEnum.Updated), eventData: exports.WebhookSectionSchema }));
51
- exports.SectionDeletedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.SectionWebhookEventEnum.Deleted), eventData: exports.WebhookSectionSchema }));
52
- exports.SectionArchivedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.SectionWebhookEventEnum.Archived), eventData: exports.WebhookSectionSchema }));
53
- exports.SectionUnarchivedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.SectionWebhookEventEnum.Unarchived), eventData: exports.WebhookSectionSchema }));
@@ -1,68 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TaskDeletedPayloadSchema = exports.TaskUncompletedPayloadSchema = exports.TaskCompletedPayloadSchema = exports.TaskUpdatedPayloadSchema = exports.TaskAddedPayloadSchema = exports.TaskUpdatedExtraSchema = exports.UpdateIntentSchema = exports.UPDATE_INTENTS = exports.TASK_WEBHOOK_EVENTS = exports.TaskWebhookEventEnum = void 0;
4
- const zod_1 = require("zod");
5
- const types_1 = require("../tasks/types");
6
- const envelope_1 = require("./envelope");
7
- /**
8
- * Enum-like object of task (`item:*`) webhook event names. Single source of
9
- * truth for the discriminator values — `TASK_WEBHOOK_EVENTS` and every
10
- * `z.literal()` below derive from it.
11
- */
12
- exports.TaskWebhookEventEnum = {
13
- Added: 'item:added',
14
- Updated: 'item:updated',
15
- Completed: 'item:completed',
16
- Uncompleted: 'item:uncompleted',
17
- Deleted: 'item:deleted',
18
- };
19
- /**
20
- * Webhook events that carry a {@link Task} as their `eventData`.
21
- *
22
- * The on-the-wire event names remain `item:*` for historical reasons; the
23
- * SDK types call them `Task*` to match the rest of the public API where the
24
- * resource is named `Task`.
25
- */
26
- exports.TASK_WEBHOOK_EVENTS = [
27
- exports.TaskWebhookEventEnum.Added,
28
- exports.TaskWebhookEventEnum.Updated,
29
- exports.TaskWebhookEventEnum.Completed,
30
- exports.TaskWebhookEventEnum.Uncompleted,
31
- exports.TaskWebhookEventEnum.Deleted,
32
- ];
33
- /**
34
- * Possible values for the `updateIntent` field on `item:updated`'s
35
- * `eventDataExtra`. `item_updated` is the default; the others narrow the
36
- * reason for the update (for example, a recurring completion or a change of
37
- * assignee).
38
- *
39
- * @see https://developer.todoist.com/sync/v1/#webhooks (Events Extra)
40
- */
41
- exports.UPDATE_INTENTS = [
42
- 'item_updated',
43
- 'item_completed',
44
- 'item_uncompleted',
45
- 'responsible_uid_changed',
46
- ];
47
- /**
48
- * An unrecognised value from a future backend release degrades gracefully to
49
- * `'item_updated'` rather than crashing the whole payload parse.
50
- */
51
- exports.UpdateIntentSchema = zod_1.z.enum(exports.UPDATE_INTENTS).catch('item_updated');
52
- /**
53
- * Extra info delivered alongside an `item:updated` event when the initiator
54
- * is the acting user. Contains the pre-update task state plus the reason for
55
- * the update — useful for diffing or for distinguishing manual edits from
56
- * recurring-task completions.
57
- *
58
- * @see https://developer.todoist.com/sync/v1/#webhooks (Events Extra)
59
- */
60
- exports.TaskUpdatedExtraSchema = zod_1.z.object({
61
- oldItem: types_1.TaskSchema,
62
- updateIntent: exports.UpdateIntentSchema,
63
- });
64
- exports.TaskAddedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.TaskWebhookEventEnum.Added), eventData: types_1.TaskSchema }));
65
- exports.TaskUpdatedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.TaskWebhookEventEnum.Updated), eventData: types_1.TaskSchema, eventDataExtra: exports.TaskUpdatedExtraSchema.optional() }));
66
- exports.TaskCompletedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.TaskWebhookEventEnum.Completed), eventData: types_1.TaskSchema }));
67
- exports.TaskUncompletedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.TaskWebhookEventEnum.Uncompleted), eventData: types_1.TaskSchema }));
68
- exports.TaskDeletedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.TaskWebhookEventEnum.Deleted), eventData: types_1.TaskSchema }));
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WebhookEventSchema = exports.WebhookPayloadSchema = void 0;
4
- const zod_1 = require("zod");
5
- const types_1 = require("../apps/types");
6
- Object.defineProperty(exports, "WebhookEventSchema", { enumerable: true, get: function () { return types_1.WebhookEventSchema; } });
7
- const comments_1 = require("./comments");
8
- const filters_1 = require("./filters");
9
- const labels_1 = require("./labels");
10
- const projects_1 = require("./projects");
11
- const reminders_1 = require("./reminders");
12
- const sections_1 = require("./sections");
13
- const tasks_1 = require("./tasks");
14
- /**
15
- * Wrapper schema for an incoming webhook payload.
16
- *
17
- * The backend sends snake_case keys and uses the public event form
18
- * (`item:added`) in the `event_name` field, so consumers using
19
- * `parseWebhookPayload` receive camelCase fields directly.
20
- *
21
- * Every {@link WebhookEvent} is typed today: `item:*` events carry a parsed
22
- * {@link Task}; `note:*` events carry a parsed comment (item-comment or
23
- * project-comment); `label:*` events carry a parsed label; `project:*`
24
- * events carry a parsed {@link Project} (personal or workspace);
25
- * `section:*` events carry a parsed {@link WebhookSection}; `filter:*`
26
- * events carry a parsed {@link Filter}; `reminder:fired` carries a parsed
27
- * {@link WebhookFiredReminder}.
28
- */
29
- exports.WebhookPayloadSchema = zod_1.z.discriminatedUnion('eventName', [
30
- tasks_1.TaskAddedPayloadSchema,
31
- tasks_1.TaskUpdatedPayloadSchema,
32
- tasks_1.TaskCompletedPayloadSchema,
33
- tasks_1.TaskUncompletedPayloadSchema,
34
- tasks_1.TaskDeletedPayloadSchema,
35
- comments_1.CommentAddedPayloadSchema,
36
- comments_1.CommentUpdatedPayloadSchema,
37
- comments_1.CommentDeletedPayloadSchema,
38
- labels_1.LabelAddedPayloadSchema,
39
- labels_1.LabelUpdatedPayloadSchema,
40
- labels_1.LabelDeletedPayloadSchema,
41
- projects_1.ProjectAddedPayloadSchema,
42
- projects_1.ProjectUpdatedPayloadSchema,
43
- projects_1.ProjectDeletedPayloadSchema,
44
- projects_1.ProjectArchivedPayloadSchema,
45
- projects_1.ProjectUnarchivedPayloadSchema,
46
- sections_1.SectionAddedPayloadSchema,
47
- sections_1.SectionUpdatedPayloadSchema,
48
- sections_1.SectionDeletedPayloadSchema,
49
- sections_1.SectionArchivedPayloadSchema,
50
- sections_1.SectionUnarchivedPayloadSchema,
51
- filters_1.FilterAddedPayloadSchema,
52
- filters_1.FilterUpdatedPayloadSchema,
53
- filters_1.FilterDeletedPayloadSchema,
54
- reminders_1.ReminderFiredPayloadSchema,
55
- ]);
@@ -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,154 +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.WorkspaceUserTaskSchema = exports.MemberActivityInfoSchema = exports.WorkspaceSchema = exports.WorkspacePropertiesSchema = exports.WorkspaceLimitsSchema = exports.WorkspacePlanSchema = exports.WORKSPACE_PLANS = exports.JoinWorkspaceResultSchema = exports.WorkspacePlanDetailsSchema = exports.WORKSPACE_PLAN_STATUSES = exports.WORKSPACE_CURRENT_PLANS = exports.FormattedPriceListingSchema = exports.PlanPriceSchema = exports.WorkspaceInvitationSchema = exports.WorkspaceUserSchema = exports.WorkspaceRoleSchema = exports.WORKSPACE_ROLES = exports.COLLABORATOR_ROLES = void 0;
15
- const zod_1 = require("zod");
16
- const common_1 = require("../common");
17
- const types_1 = require("../tasks/types");
18
- /** Available project collaborator roles. */
19
- exports.COLLABORATOR_ROLES = [
20
- 'CREATOR',
21
- 'ADMIN',
22
- 'READ_WRITE',
23
- 'EDIT_ONLY',
24
- 'COMPLETE_ONLY',
25
- ];
26
- /**
27
- * Available workspace roles.
28
- */
29
- exports.WORKSPACE_ROLES = ['ADMIN', 'MEMBER', 'GUEST'];
30
- exports.WorkspaceRoleSchema = zod_1.z.enum(exports.WORKSPACE_ROLES);
31
- exports.WorkspaceUserSchema = zod_1.z.object({
32
- userId: zod_1.z.string(),
33
- workspaceId: zod_1.z.string(),
34
- userEmail: zod_1.z.string(),
35
- fullName: zod_1.z.string(),
36
- timezone: zod_1.z.string(),
37
- role: exports.WorkspaceRoleSchema,
38
- imageId: zod_1.z.string().nullable(),
39
- isDeleted: zod_1.z.boolean().default(false),
40
- });
41
- exports.WorkspaceInvitationSchema = zod_1.z.object({
42
- id: zod_1.z.string().default('0'),
43
- inviterId: zod_1.z.string(),
44
- userEmail: zod_1.z.string(),
45
- workspaceId: zod_1.z.string(),
46
- role: exports.WorkspaceRoleSchema,
47
- });
48
- exports.PlanPriceSchema = zod_1.z.object({
49
- currency: zod_1.z.string(),
50
- amount: zod_1.z.union([zod_1.z.number(), zod_1.z.string()]),
51
- interval: zod_1.z.string().optional(),
52
- });
53
- exports.FormattedPriceListingSchema = zod_1.z.object({
54
- currency: zod_1.z.string().optional(),
55
- amount: zod_1.z.number().optional(),
56
- interval: zod_1.z.string().optional(),
57
- formatted: zod_1.z.string().optional(),
58
- });
59
- /** Available workspace plan names. */
60
- exports.WORKSPACE_CURRENT_PLANS = ['Business', 'Starter'];
61
- /** Available workspace plan statuses. */
62
- exports.WORKSPACE_PLAN_STATUSES = [
63
- 'Active',
64
- 'Downgraded',
65
- 'Cancelled',
66
- 'NeverSubscribed',
67
- ];
68
- exports.WorkspacePlanDetailsSchema = zod_1.z.object({
69
- currentMemberCount: zod_1.z.number(),
70
- currentPlan: zod_1.z.enum(exports.WORKSPACE_CURRENT_PLANS),
71
- currentPlanStatus: zod_1.z.enum(exports.WORKSPACE_PLAN_STATUSES),
72
- downgradeAt: zod_1.z.string().nullable(),
73
- currentActiveProjects: zod_1.z.number(),
74
- maximumActiveProjects: zod_1.z.number(),
75
- priceList: zod_1.z.array(exports.FormattedPriceListingSchema),
76
- workspaceId: common_1.StringOrNumberSchema,
77
- isTrialing: zod_1.z.boolean(),
78
- trialEndsAt: zod_1.z.string().nullable(),
79
- cancelAtPeriodEnd: zod_1.z.boolean(),
80
- hasTrialed: zod_1.z.boolean(),
81
- planPrice: exports.PlanPriceSchema.nullable(),
82
- hasBillingPortal: zod_1.z.boolean(),
83
- hasBillingPortalSwitchToAnnual: zod_1.z.boolean(),
84
- });
85
- exports.JoinWorkspaceResultSchema = zod_1.z.object({
86
- customSortingApplied: zod_1.z.boolean(),
87
- projectSortPreference: zod_1.z.string(),
88
- role: exports.WorkspaceRoleSchema,
89
- userId: zod_1.z.string(),
90
- workspaceId: zod_1.z.string(),
91
- });
92
- /**
93
- * Available workspace plans.
94
- */
95
- exports.WORKSPACE_PLANS = ['STARTER', 'BUSINESS'];
96
- exports.WorkspacePlanSchema = zod_1.z.enum(exports.WORKSPACE_PLANS);
97
- /**
98
- * Workspace resource limits.
99
- */
100
- exports.WorkspaceLimitsSchema = zod_1.z
101
- .object({
102
- current: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).nullable(),
103
- next: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).nullable(),
104
- })
105
- .catchall(zod_1.z.any());
106
- /**
107
- * Workspace properties (flexible object for unknown fields).
108
- */
109
- exports.WorkspacePropertiesSchema = zod_1.z.record(zod_1.z.string(), zod_1.z.unknown());
110
- /**
111
- * Represents a workspace in Todoist.
112
- */
113
- exports.WorkspaceSchema = zod_1.z
114
- .object({
115
- id: common_1.StringOrNumberSchema,
116
- name: zod_1.z.string(),
117
- plan: exports.WorkspacePlanSchema,
118
- role: exports.WorkspaceRoleSchema.optional(),
119
- inviteCode: zod_1.z.string(),
120
- isLinkSharingEnabled: zod_1.z.boolean(),
121
- isGuestAllowed: zod_1.z.boolean(),
122
- limits: exports.WorkspaceLimitsSchema.optional(),
123
- logoBig: zod_1.z.string().nullish(),
124
- logoMedium: zod_1.z.string().nullish(),
125
- logoSmall: zod_1.z.string().nullish(),
126
- logoS640: zod_1.z.string().nullish(),
127
- createdAt: zod_1.z.coerce.date().optional(),
128
- dateCreated: zod_1.z.coerce.date().optional(),
129
- creatorId: common_1.StringOrNumberSchema,
130
- properties: exports.WorkspacePropertiesSchema,
131
- })
132
- .transform((_a) => {
133
- var { dateCreated, createdAt } = _a, rest = __rest(_a, ["dateCreated", "createdAt"]);
134
- return (Object.assign(Object.assign({}, rest), { createdAt: createdAt !== null && createdAt !== void 0 ? createdAt : dateCreated }));
135
- });
136
- exports.MemberActivityInfoSchema = zod_1.z.object({
137
- userId: zod_1.z.string(),
138
- tasksAssigned: zod_1.z.number().int(),
139
- tasksOverdue: zod_1.z.number().int(),
140
- });
141
- exports.WorkspaceUserTaskSchema = zod_1.z.object({
142
- id: zod_1.z.string(),
143
- content: zod_1.z.string(),
144
- responsibleUid: zod_1.z.string().nullable(),
145
- due: types_1.DueDateSchema.nullable(),
146
- deadline: types_1.DeadlineSchema.nullable(),
147
- labels: zod_1.z.array(zod_1.z.string()),
148
- notesCount: zod_1.z.number().int(),
149
- projectId: zod_1.z.string(),
150
- projectName: zod_1.z.string(),
151
- priority: zod_1.z.number().int(),
152
- description: zod_1.z.string(),
153
- isOverdue: zod_1.z.boolean(),
154
- });
@@ -1,58 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeObjectTypeForApi = normalizeObjectTypeForApi;
4
- exports.denormalizeObjectTypeFromApi = denormalizeObjectTypeFromApi;
5
- exports.normalizeObjectEventTypeForApi = normalizeObjectEventTypeForApi;
6
- /**
7
- * Converts modern SDK object type naming to legacy API naming.
8
- * Maps 'task' -> 'item' and 'comment' -> 'note' for API requests.
9
- * Other values pass through unchanged.
10
- *
11
- * @internal
12
- * @param objectType The object type using modern naming.
13
- * @returns The object type using legacy API naming.
14
- */
15
- function normalizeObjectTypeForApi(objectType) {
16
- if (!objectType)
17
- return objectType;
18
- if (objectType === 'task')
19
- return 'item';
20
- if (objectType === 'comment')
21
- return 'note';
22
- return objectType;
23
- }
24
- /**
25
- * Converts legacy API object type naming to modern SDK naming.
26
- * Maps 'item' -> 'task' and 'note' -> 'comment' for SDK responses.
27
- * Other values pass through unchanged.
28
- *
29
- * @internal
30
- * @param objectType The object type using legacy API naming.
31
- * @returns The object type using modern SDK naming.
32
- */
33
- function denormalizeObjectTypeFromApi(objectType) {
34
- if (!objectType)
35
- return objectType;
36
- if (objectType === 'item')
37
- return 'task';
38
- if (objectType === 'note')
39
- return 'comment';
40
- return objectType;
41
- }
42
- /**
43
- * Normalizes an `ActivityObjectEventType` filter string for the API,
44
- * converting modern object type names to legacy API names.
45
- * e.g. 'task:added' -> 'item:added', 'comment:' -> 'note:', ':deleted' -> ':deleted'
46
- *
47
- * @internal
48
- */
49
- function normalizeObjectEventTypeForApi(filter) {
50
- var _a, _b;
51
- const colonIndex = filter.indexOf(':');
52
- if (colonIndex === -1) {
53
- return (_a = normalizeObjectTypeForApi(filter)) !== null && _a !== void 0 ? _a : filter;
54
- }
55
- const objectPart = filter.slice(0, colonIndex);
56
- const eventPart = filter.slice(colonIndex); // includes the colon
57
- return `${(_b = normalizeObjectTypeForApi(objectPart)) !== null && _b !== void 0 ? _b : objectPart}${eventPart}`;
58
- }
@@ -1,69 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.customCamelCase = customCamelCase;
7
- exports.camelCaseKeys = camelCaseKeys;
8
- exports.snakeCaseKeys = snakeCaseKeys;
9
- const camelcase_1 = __importDefault(require("camelcase"));
10
- const emoji_regex_1 = __importDefault(require("emoji-regex"));
11
- /**
12
- * Checks if a string is a solitary emoji
13
- */
14
- function isEmojiKey(input) {
15
- const regex = (0, emoji_regex_1.default)();
16
- const match = input.match(regex);
17
- return match !== null && match.join('') === input;
18
- }
19
- /**
20
- * Custom camelCase function that preserves emoji strings
21
- */
22
- function customCamelCase(input) {
23
- // If the value is a solitary emoji string, return the key as-is
24
- if (isEmojiKey(input)) {
25
- return input;
26
- }
27
- return (0, camelcase_1.default)(input);
28
- }
29
- /**
30
- * Converts object keys from snake_case to camelCase recursively
31
- */
32
- function camelCaseKeys(obj) {
33
- if (obj === null || obj === undefined) {
34
- return obj;
35
- }
36
- if (Array.isArray(obj)) {
37
- return obj.map((item) => camelCaseKeys(item));
38
- }
39
- if (typeof obj === 'object' && obj.constructor === Object) {
40
- const converted = {};
41
- for (const [key, value] of Object.entries(obj)) {
42
- const camelKey = customCamelCase(key);
43
- converted[camelKey] = camelCaseKeys(value);
44
- }
45
- return converted;
46
- }
47
- return obj;
48
- }
49
- /**
50
- * Converts object keys from camelCase to snake_case recursively
51
- */
52
- function snakeCaseKeys(obj) {
53
- if (obj === null || obj === undefined) {
54
- return obj;
55
- }
56
- if (Array.isArray(obj)) {
57
- return obj.map((item) => snakeCaseKeys(item));
58
- }
59
- if (typeof obj === 'object' && obj.constructor === Object) {
60
- const converted = {};
61
- for (const [key, value] of Object.entries(obj)) {
62
- // Convert camelCase to snake_case
63
- const snakeKey = key.replace(/([A-Z])/g, '_$1').toLowerCase();
64
- converted[snakeKey] = snakeCaseKeys(value);
65
- }
66
- return converted;
67
- }
68
- return obj;
69
- }