@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,96 +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.CommentDeletedPayloadSchema = exports.CommentUpdatedPayloadSchema = exports.CommentAddedPayloadSchema = exports.WebhookCommentSchema = exports.WebhookProjectCommentSchema = exports.WebhookItemCommentSchema = exports.COMMENT_WEBHOOK_EVENTS = exports.CommentWebhookEventEnum = void 0;
15
- const zod_1 = require("zod");
16
- const types_1 = require("../comments/types");
17
- const types_2 = require("../tasks/types");
18
- const envelope_1 = require("./envelope");
19
- /**
20
- * Enum-like object of comment (`note:*`) webhook event names. Single source
21
- * of truth for the discriminator values — `COMMENT_WEBHOOK_EVENTS` and every
22
- * `z.literal()` below derive from it.
23
- *
24
- * The on-the-wire event names remain `note:*` for historical reasons; the
25
- * SDK types use `Comment*` to match the rest of the public API where the
26
- * resource is named `Comment`.
27
- */
28
- exports.CommentWebhookEventEnum = {
29
- Added: 'note:added',
30
- Updated: 'note:updated',
31
- Deleted: 'note:deleted',
32
- };
33
- /**
34
- * Webhook events that carry a comment as their `eventData`.
35
- */
36
- exports.COMMENT_WEBHOOK_EVENTS = [
37
- exports.CommentWebhookEventEnum.Added,
38
- exports.CommentWebhookEventEnum.Updated,
39
- exports.CommentWebhookEventEnum.Deleted,
40
- ];
41
- /**
42
- * Fields common to both item and project comment payloads.
43
- *
44
- * `postedAt` and `postedUid` are nullable here (unlike
45
- * {@link RawCommentSchema}) because webhook payloads may omit them — for
46
- * example when the poster could not be resolved, or on a deleted-note
47
- * tombstone.
48
- */
49
- const WebhookCommentBaseSchema = zod_1.z.object({
50
- id: zod_1.z.string(),
51
- content: zod_1.z.string(),
52
- postedAt: zod_1.z.coerce.date().nullable(),
53
- postedUid: zod_1.z.string().nullable(),
54
- fileAttachment: types_1.AttachmentSchema.nullable(),
55
- uidsToNotify: zod_1.z.array(zod_1.z.string()).nullable(),
56
- reactions: zod_1.z.record(zod_1.z.string(), zod_1.z.array(zod_1.z.string())).nullable(),
57
- isDeleted: zod_1.z.boolean(),
58
- });
59
- /**
60
- * A comment attached to a task, delivered in a webhook payload.
61
- *
62
- * Webhook item-comment payloads carry two fields that don't appear on the
63
- * REST comment resource: `url` (the direct task URL) and `item` (the full
64
- * embedded {@link Task}). Both are parsed here so consumers handling a
65
- * `note:added` event also get the task it belongs to.
66
- *
67
- * `itemId` is exposed as `taskId` to match the rest of the SDK surface.
68
- */
69
- exports.WebhookItemCommentSchema = WebhookCommentBaseSchema.extend({
70
- itemId: zod_1.z.string(),
71
- url: zod_1.z.string(),
72
- item: types_2.TaskSchema,
73
- })
74
- .strict()
75
- .transform((_a) => {
76
- var { itemId } = _a, rest = __rest(_a, ["itemId"]);
77
- return (Object.assign(Object.assign({}, rest), { taskId: itemId }));
78
- });
79
- /**
80
- * A comment attached to a project, delivered in a webhook payload.
81
- *
82
- * Project comments do not carry the extra `url` or embedded project fields
83
- * that item comments carry for the parent task.
84
- */
85
- exports.WebhookProjectCommentSchema = WebhookCommentBaseSchema.extend({
86
- projectId: zod_1.z.string(),
87
- }).strict();
88
- /**
89
- * The `eventData` of a `note:*` webhook payload — either an item comment
90
- * (includes `taskId` and an embedded {@link Task}) or a project comment
91
- * (includes `projectId`). Narrow with `'taskId' in eventData`.
92
- */
93
- exports.WebhookCommentSchema = zod_1.z.union([exports.WebhookItemCommentSchema, exports.WebhookProjectCommentSchema]);
94
- exports.CommentAddedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.CommentWebhookEventEnum.Added), eventData: exports.WebhookCommentSchema }));
95
- exports.CommentUpdatedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.CommentWebhookEventEnum.Updated), eventData: exports.WebhookCommentSchema }));
96
- exports.CommentDeletedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.CommentWebhookEventEnum.Deleted), eventData: exports.WebhookCommentSchema }));
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseWebhookEnvelopeShape = exports.WebhookInitiatorSchema = void 0;
4
- const zod_1 = require("zod");
5
- const types_1 = require("../apps/types");
6
- /**
7
- * Collaborator info for the user that triggered a webhook event.
8
- * @see https://developer.todoist.com/sync/v1/#webhooks
9
- */
10
- exports.WebhookInitiatorSchema = zod_1.z.object({
11
- id: zod_1.z.string(),
12
- fullName: zod_1.z.string(),
13
- email: zod_1.z.string(),
14
- imageId: zod_1.z.string().nullable(),
15
- isPremium: zod_1.z.boolean(),
16
- });
17
- /**
18
- * Fields common to every webhook payload, regardless of `eventName`.
19
- * Meant to be spread into per-event variant schemas.
20
- */
21
- exports.BaseWebhookEnvelopeShape = {
22
- version: types_1.WebhookVersionSchema,
23
- userId: zod_1.z.string(),
24
- initiator: exports.WebhookInitiatorSchema,
25
- triggeredAt: zod_1.z.coerce.date(),
26
- };
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FilterDeletedPayloadSchema = exports.FilterUpdatedPayloadSchema = exports.FilterAddedPayloadSchema = exports.FILTER_WEBHOOK_EVENTS = exports.FilterWebhookEventEnum = void 0;
4
- const zod_1 = require("zod");
5
- const filters_1 = require("../sync/resources/filters");
6
- const envelope_1 = require("./envelope");
7
- /**
8
- * Enum-like object of filter (`filter:*`) webhook event names. Single
9
- * source of truth for the discriminator values — `FILTER_WEBHOOK_EVENTS`
10
- * and every `z.literal()` below derive from it.
11
- */
12
- exports.FilterWebhookEventEnum = {
13
- Added: 'filter:added',
14
- Updated: 'filter:updated',
15
- Deleted: 'filter:deleted',
16
- };
17
- /** Webhook events that carry a filter as their `eventData`. */
18
- exports.FILTER_WEBHOOK_EVENTS = [
19
- exports.FilterWebhookEventEnum.Added,
20
- exports.FilterWebhookEventEnum.Updated,
21
- exports.FilterWebhookEventEnum.Deleted,
22
- ];
23
- /**
24
- * Webhook filter payloads match the shared {@link Filter} resource shape,
25
- * so `eventData` reuses `FilterSchema` directly — no webhook-specific
26
- * schema is needed.
27
- */
28
- exports.FilterAddedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.FilterWebhookEventEnum.Added), eventData: filters_1.FilterSchema }));
29
- exports.FilterUpdatedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.FilterWebhookEventEnum.Updated), eventData: filters_1.FilterSchema }));
30
- exports.FilterDeletedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.FilterWebhookEventEnum.Deleted), eventData: filters_1.FilterSchema }));
@@ -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 });