@doist/todoist-sdk 9.5.0 → 9.7.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.
@@ -1,10 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SectionSchema = void 0;
3
+ exports.SectionSchema = exports.SectionBaseSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const url_helpers_1 = require("../../utils/url-helpers");
6
- exports.SectionSchema = zod_1.z
7
- .object({
6
+ /**
7
+ * Raw section fields (the persisted shape). Exposed so schemas that extend
8
+ * or override a field — notably the webhook variant — can reuse the base
9
+ * without duplicating every field.
10
+ */
11
+ exports.SectionBaseSchema = zod_1.z.object({
8
12
  id: zod_1.z.string(),
9
13
  userId: zod_1.z.string(),
10
14
  projectId: zod_1.z.string(),
@@ -16,7 +20,5 @@ exports.SectionSchema = zod_1.z
16
20
  isArchived: zod_1.z.boolean(),
17
21
  isDeleted: zod_1.z.boolean(),
18
22
  isCollapsed: zod_1.z.boolean(),
19
- })
20
- .transform((data) => {
21
- return Object.assign(Object.assign({}, data), { url: (0, url_helpers_1.getSectionUrl)(data.id, data.name) });
22
23
  });
24
+ exports.SectionSchema = exports.SectionBaseSchema.transform((data) => (Object.assign(Object.assign({}, data), { url: (0, url_helpers_1.getSectionUrl)(data.id, data.name) })));
@@ -0,0 +1,30 @@
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 }));
@@ -16,6 +16,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./comments"), exports);
18
18
  __exportStar(require("./envelope"), exports);
19
+ __exportStar(require("./filters"), exports);
19
20
  __exportStar(require("./labels"), exports);
21
+ __exportStar(require("./projects"), exports);
22
+ __exportStar(require("./reminders"), exports);
23
+ __exportStar(require("./sections"), exports);
20
24
  __exportStar(require("./tasks"), exports);
21
25
  __exportStar(require("./types"), exports);
@@ -0,0 +1,36 @@
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 }));
@@ -0,0 +1,35 @@
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 }));
@@ -0,0 +1,48 @@
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. Surfaces the computed `url` so the exposed shape
36
+ * matches {@link Section}.
37
+ */
38
+ exports.WebhookSectionSchema = types_1.SectionBaseSchema.extend({
39
+ updatedAt: zod_1.z.coerce
40
+ .date()
41
+ .nullish()
42
+ .transform((value) => value !== null && value !== void 0 ? value : null),
43
+ }).transform((data) => (Object.assign(Object.assign({}, data), { url: (0, url_helpers_1.getSectionUrl)(data.id, data.name) })));
44
+ exports.SectionAddedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.SectionWebhookEventEnum.Added), eventData: exports.WebhookSectionSchema }));
45
+ exports.SectionUpdatedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.SectionWebhookEventEnum.Updated), eventData: exports.WebhookSectionSchema }));
46
+ exports.SectionDeletedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.SectionWebhookEventEnum.Deleted), eventData: exports.WebhookSectionSchema }));
47
+ exports.SectionArchivedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.SectionWebhookEventEnum.Archived), eventData: exports.WebhookSectionSchema }));
48
+ 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,30 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WebhookEventSchema = exports.WebhookPayloadSchema = exports.UntypedWebhookPayloadSchema = void 0;
3
+ exports.WebhookEventSchema = exports.WebhookPayloadSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const types_1 = require("../apps/types");
6
6
  Object.defineProperty(exports, "WebhookEventSchema", { enumerable: true, get: function () { return types_1.WebhookEventSchema; } });
7
7
  const comments_1 = require("./comments");
8
- const envelope_1 = require("./envelope");
8
+ const filters_1 = require("./filters");
9
9
  const labels_1 = require("./labels");
10
+ const projects_1 = require("./projects");
11
+ const reminders_1 = require("./reminders");
12
+ const sections_1 = require("./sections");
10
13
  const tasks_1 = require("./tasks");
11
- /**
12
- * Events whose payloads have been narrowed per resource. Each phase adds to
13
- * this list; {@link UntypedWebhookPayloadSchema} below is derived by taking
14
- * every {@link WebhookEvent} not present here.
15
- */
16
- const TYPED_WEBHOOK_EVENTS = [
17
- ...tasks_1.TASK_WEBHOOK_EVENTS,
18
- ...comments_1.COMMENT_WEBHOOK_EVENTS,
19
- ...labels_1.LABEL_WEBHOOK_EVENTS,
20
- ];
21
- const untypedEventNames = types_1.WEBHOOK_EVENTS.filter((event) => !TYPED_WEBHOOK_EVENTS.includes(event));
22
- /**
23
- * A single branch covering every event whose payload has not yet been typed
24
- * per resource. Follow-up PRs will replace slices of this with dedicated
25
- * variants (projects, sections, filters, reminders).
26
- */
27
- exports.UntypedWebhookPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.enum(untypedEventNames), eventData: zod_1.z.unknown(), eventDataExtra: zod_1.z.unknown().optional() }));
28
14
  /**
29
15
  * Wrapper schema for an incoming webhook payload.
30
16
  *
@@ -32,11 +18,13 @@ exports.UntypedWebhookPayloadSchema = zod_1.z.object(Object.assign(Object.assign
32
18
  * (`item:added`) in the `event_name` field, so consumers using
33
19
  * `parseWebhookPayload` receive camelCase fields directly.
34
20
  *
35
- * Typed today: `item:*` events carry a parsed {@link Task}; `note:*` events
36
- * carry a parsed comment (item-comment or project-comment); `label:*` events
37
- * carry a parsed label. Other events still expose `eventData` as `unknown`;
38
- * they will be narrowed in follow-up PRs (projects, sections, filters,
39
- * reminders).
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}.
40
28
  */
41
29
  exports.WebhookPayloadSchema = zod_1.z.discriminatedUnion('eventName', [
42
30
  tasks_1.TaskAddedPayloadSchema,
@@ -50,5 +38,18 @@ exports.WebhookPayloadSchema = zod_1.z.discriminatedUnion('eventName', [
50
38
  labels_1.LabelAddedPayloadSchema,
51
39
  labels_1.LabelUpdatedPayloadSchema,
52
40
  labels_1.LabelDeletedPayloadSchema,
53
- exports.UntypedWebhookPayloadSchema,
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,
54
55
  ]);
@@ -1,7 +1,11 @@
1
1
  import { z } from 'zod';
2
2
  import { getSectionUrl } from '../../utils/url-helpers.js';
3
- export const SectionSchema = z
4
- .object({
3
+ /**
4
+ * Raw section fields (the persisted shape). Exposed so schemas that extend
5
+ * or override a field — notably the webhook variant — can reuse the base
6
+ * without duplicating every field.
7
+ */
8
+ export const SectionBaseSchema = z.object({
5
9
  id: z.string(),
6
10
  userId: z.string(),
7
11
  projectId: z.string(),
@@ -13,7 +17,5 @@ export const SectionSchema = z
13
17
  isArchived: z.boolean(),
14
18
  isDeleted: z.boolean(),
15
19
  isCollapsed: z.boolean(),
16
- })
17
- .transform((data) => {
18
- return Object.assign(Object.assign({}, data), { url: getSectionUrl(data.id, data.name) });
19
20
  });
21
+ export const SectionSchema = SectionBaseSchema.transform((data) => (Object.assign(Object.assign({}, data), { url: getSectionUrl(data.id, data.name) })));
@@ -0,0 +1,27 @@
1
+ import { z } from 'zod';
2
+ import { FilterSchema } from '../sync/resources/filters.js';
3
+ import { BaseWebhookEnvelopeShape } from './envelope.js';
4
+ /**
5
+ * Enum-like object of filter (`filter:*`) webhook event names. Single
6
+ * source of truth for the discriminator values — `FILTER_WEBHOOK_EVENTS`
7
+ * and every `z.literal()` below derive from it.
8
+ */
9
+ export const FilterWebhookEventEnum = {
10
+ Added: 'filter:added',
11
+ Updated: 'filter:updated',
12
+ Deleted: 'filter:deleted',
13
+ };
14
+ /** Webhook events that carry a filter as their `eventData`. */
15
+ export const FILTER_WEBHOOK_EVENTS = [
16
+ FilterWebhookEventEnum.Added,
17
+ FilterWebhookEventEnum.Updated,
18
+ FilterWebhookEventEnum.Deleted,
19
+ ];
20
+ /**
21
+ * Webhook filter payloads match the shared {@link Filter} resource shape,
22
+ * so `eventData` reuses `FilterSchema` directly — no webhook-specific
23
+ * schema is needed.
24
+ */
25
+ export const FilterAddedPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(FilterWebhookEventEnum.Added), eventData: FilterSchema }));
26
+ export const FilterUpdatedPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(FilterWebhookEventEnum.Updated), eventData: FilterSchema }));
27
+ export const FilterDeletedPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(FilterWebhookEventEnum.Deleted), eventData: FilterSchema }));
@@ -1,5 +1,9 @@
1
1
  export * from './comments.js';
2
2
  export * from './envelope.js';
3
+ export * from './filters.js';
3
4
  export * from './labels.js';
5
+ export * from './projects.js';
6
+ export * from './reminders.js';
7
+ export * from './sections.js';
4
8
  export * from './tasks.js';
5
9
  export * from './types.js';
@@ -0,0 +1,33 @@
1
+ import { z } from 'zod';
2
+ import { ProjectSchema } from '../projects/types.js';
3
+ import { BaseWebhookEnvelopeShape } from './envelope.js';
4
+ /**
5
+ * Enum-like object of project (`project:*`) webhook event names. Single
6
+ * source of truth for the discriminator values — `PROJECT_WEBHOOK_EVENTS`
7
+ * and every `z.literal()` below derive from it.
8
+ */
9
+ export const ProjectWebhookEventEnum = {
10
+ Added: 'project:added',
11
+ Updated: 'project:updated',
12
+ Deleted: 'project:deleted',
13
+ Archived: 'project:archived',
14
+ Unarchived: 'project:unarchived',
15
+ };
16
+ /** Webhook events that carry a project as their `eventData`. */
17
+ export const PROJECT_WEBHOOK_EVENTS = [
18
+ ProjectWebhookEventEnum.Added,
19
+ ProjectWebhookEventEnum.Updated,
20
+ ProjectWebhookEventEnum.Deleted,
21
+ ProjectWebhookEventEnum.Archived,
22
+ ProjectWebhookEventEnum.Unarchived,
23
+ ];
24
+ /**
25
+ * Webhook project payloads match the shape of the shared {@link Project}
26
+ * resource — either a personal or a workspace project. No webhook-specific
27
+ * schema is needed; `ProjectSchema` already dispatches on `workspaceId`.
28
+ */
29
+ export const ProjectAddedPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(ProjectWebhookEventEnum.Added), eventData: ProjectSchema }));
30
+ export const ProjectUpdatedPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(ProjectWebhookEventEnum.Updated), eventData: ProjectSchema }));
31
+ export const ProjectDeletedPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(ProjectWebhookEventEnum.Deleted), eventData: ProjectSchema }));
32
+ export const ProjectArchivedPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(ProjectWebhookEventEnum.Archived), eventData: ProjectSchema }));
33
+ export const ProjectUnarchivedPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(ProjectWebhookEventEnum.Unarchived), eventData: ProjectSchema }));
@@ -0,0 +1,32 @@
1
+ import { z } from 'zod';
2
+ import { REMINDER_TYPES, ReminderBaseSchema } from '../sync/resources/reminders.js';
3
+ import { DueDateSchema } from '../tasks/types.js';
4
+ import { BaseWebhookEnvelopeShape } from './envelope.js';
5
+ /**
6
+ * Enum-like object of reminder (`reminder:*`) webhook event names. Single
7
+ * source of truth for the discriminator values — `REMINDER_WEBHOOK_EVENTS`
8
+ * and every `z.literal()` below derive from it.
9
+ */
10
+ export const ReminderWebhookEventEnum = {
11
+ Fired: 'reminder:fired',
12
+ };
13
+ /** Webhook events that carry a fired-reminder as their `eventData`. */
14
+ export const REMINDER_WEBHOOK_EVENTS = [
15
+ ReminderWebhookEventEnum.Fired,
16
+ ];
17
+ /**
18
+ * A fired-reminder notification as delivered in a webhook payload.
19
+ *
20
+ * `reminder:fired` carries a subset of the full Reminder record (closer
21
+ * to a fired-notification projection), so it doesn't line up with any of
22
+ * the {@link Reminder} discriminated variants directly. This schema
23
+ * reuses {@link ReminderBaseSchema} for the common identity fields and
24
+ * adds the fields always present on a fired notification.
25
+ */
26
+ export const WebhookFiredReminderSchema = ReminderBaseSchema.extend({
27
+ type: z.enum(REMINDER_TYPES),
28
+ isUrgent: z.boolean(),
29
+ minuteOffset: z.number().int().nullable(),
30
+ due: DueDateSchema.nullable(),
31
+ });
32
+ export const ReminderFiredPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(ReminderWebhookEventEnum.Fired), eventData: WebhookFiredReminderSchema }));
@@ -0,0 +1,45 @@
1
+ import { z } from 'zod';
2
+ import { getSectionUrl } from '../../utils/url-helpers.js';
3
+ import { SectionBaseSchema } from '../sections/types.js';
4
+ import { BaseWebhookEnvelopeShape } from './envelope.js';
5
+ /**
6
+ * Enum-like object of section (`section:*`) webhook event names. Single
7
+ * source of truth for the discriminator values — `SECTION_WEBHOOK_EVENTS`
8
+ * and every `z.literal()` below derive from it.
9
+ */
10
+ export const SectionWebhookEventEnum = {
11
+ Added: 'section:added',
12
+ Updated: 'section:updated',
13
+ Deleted: 'section:deleted',
14
+ Archived: 'section:archived',
15
+ Unarchived: 'section:unarchived',
16
+ };
17
+ /** Webhook events that carry a section as their `eventData`. */
18
+ export const SECTION_WEBHOOK_EVENTS = [
19
+ SectionWebhookEventEnum.Added,
20
+ SectionWebhookEventEnum.Updated,
21
+ SectionWebhookEventEnum.Deleted,
22
+ SectionWebhookEventEnum.Archived,
23
+ SectionWebhookEventEnum.Unarchived,
24
+ ];
25
+ /**
26
+ * A section as delivered in a webhook payload.
27
+ *
28
+ * Reuses {@link SectionBaseSchema} and overrides `updatedAt` to tolerate
29
+ * payloads that deliver it as `null` or omit the key entirely — tombstones
30
+ * and never-updated sections come through without an `updated_at` value.
31
+ * The result is normalised to `Date | null` so consumers don't have to
32
+ * handle three shapes. Surfaces the computed `url` so the exposed shape
33
+ * matches {@link Section}.
34
+ */
35
+ export const WebhookSectionSchema = SectionBaseSchema.extend({
36
+ updatedAt: z.coerce
37
+ .date()
38
+ .nullish()
39
+ .transform((value) => value !== null && value !== void 0 ? value : null),
40
+ }).transform((data) => (Object.assign(Object.assign({}, data), { url: getSectionUrl(data.id, data.name) })));
41
+ export const SectionAddedPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(SectionWebhookEventEnum.Added), eventData: WebhookSectionSchema }));
42
+ export const SectionUpdatedPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(SectionWebhookEventEnum.Updated), eventData: WebhookSectionSchema }));
43
+ export const SectionDeletedPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(SectionWebhookEventEnum.Deleted), eventData: WebhookSectionSchema }));
44
+ export const SectionArchivedPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(SectionWebhookEventEnum.Archived), eventData: WebhookSectionSchema }));
45
+ export const SectionUnarchivedPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.literal(SectionWebhookEventEnum.Unarchived), eventData: WebhookSectionSchema }));
@@ -1,26 +1,12 @@
1
1
  import { z } from 'zod';
2
- import { WEBHOOK_EVENTS, WebhookEventSchema } from '../apps/types.js';
3
- import { COMMENT_WEBHOOK_EVENTS, CommentAddedPayloadSchema, CommentDeletedPayloadSchema, CommentUpdatedPayloadSchema, } from './comments.js';
4
- import { BaseWebhookEnvelopeShape } from './envelope.js';
5
- import { LABEL_WEBHOOK_EVENTS, LabelAddedPayloadSchema, LabelDeletedPayloadSchema, LabelUpdatedPayloadSchema, } from './labels.js';
6
- import { TASK_WEBHOOK_EVENTS, TaskAddedPayloadSchema, TaskCompletedPayloadSchema, TaskDeletedPayloadSchema, TaskUncompletedPayloadSchema, TaskUpdatedPayloadSchema, } from './tasks.js';
7
- /**
8
- * Events whose payloads have been narrowed per resource. Each phase adds to
9
- * this list; {@link UntypedWebhookPayloadSchema} below is derived by taking
10
- * every {@link WebhookEvent} not present here.
11
- */
12
- const TYPED_WEBHOOK_EVENTS = [
13
- ...TASK_WEBHOOK_EVENTS,
14
- ...COMMENT_WEBHOOK_EVENTS,
15
- ...LABEL_WEBHOOK_EVENTS,
16
- ];
17
- const untypedEventNames = WEBHOOK_EVENTS.filter((event) => !TYPED_WEBHOOK_EVENTS.includes(event));
18
- /**
19
- * A single branch covering every event whose payload has not yet been typed
20
- * per resource. Follow-up PRs will replace slices of this with dedicated
21
- * variants (projects, sections, filters, reminders).
22
- */
23
- export const UntypedWebhookPayloadSchema = z.object(Object.assign(Object.assign({}, BaseWebhookEnvelopeShape), { eventName: z.enum(untypedEventNames), eventData: z.unknown(), eventDataExtra: z.unknown().optional() }));
2
+ import { WebhookEventSchema } from '../apps/types.js';
3
+ import { CommentAddedPayloadSchema, CommentDeletedPayloadSchema, CommentUpdatedPayloadSchema, } from './comments.js';
4
+ import { FilterAddedPayloadSchema, FilterDeletedPayloadSchema, FilterUpdatedPayloadSchema, } from './filters.js';
5
+ import { LabelAddedPayloadSchema, LabelDeletedPayloadSchema, LabelUpdatedPayloadSchema, } from './labels.js';
6
+ import { ProjectAddedPayloadSchema, ProjectArchivedPayloadSchema, ProjectDeletedPayloadSchema, ProjectUnarchivedPayloadSchema, ProjectUpdatedPayloadSchema, } from './projects.js';
7
+ import { ReminderFiredPayloadSchema } from './reminders.js';
8
+ import { SectionAddedPayloadSchema, SectionArchivedPayloadSchema, SectionDeletedPayloadSchema, SectionUnarchivedPayloadSchema, SectionUpdatedPayloadSchema, } from './sections.js';
9
+ import { TaskAddedPayloadSchema, TaskCompletedPayloadSchema, TaskDeletedPayloadSchema, TaskUncompletedPayloadSchema, TaskUpdatedPayloadSchema, } from './tasks.js';
24
10
  /**
25
11
  * Wrapper schema for an incoming webhook payload.
26
12
  *
@@ -28,11 +14,13 @@ export const UntypedWebhookPayloadSchema = z.object(Object.assign(Object.assign(
28
14
  * (`item:added`) in the `event_name` field, so consumers using
29
15
  * `parseWebhookPayload` receive camelCase fields directly.
30
16
  *
31
- * Typed today: `item:*` events carry a parsed {@link Task}; `note:*` events
32
- * carry a parsed comment (item-comment or project-comment); `label:*` events
33
- * carry a parsed label. Other events still expose `eventData` as `unknown`;
34
- * they will be narrowed in follow-up PRs (projects, sections, filters,
35
- * reminders).
17
+ * Every {@link WebhookEvent} is typed today: `item:*` events carry a parsed
18
+ * {@link Task}; `note:*` events carry a parsed comment (item-comment or
19
+ * project-comment); `label:*` events carry a parsed label; `project:*`
20
+ * events carry a parsed {@link Project} (personal or workspace);
21
+ * `section:*` events carry a parsed {@link WebhookSection}; `filter:*`
22
+ * events carry a parsed {@link Filter}; `reminder:fired` carries a parsed
23
+ * {@link WebhookFiredReminder}.
36
24
  */
37
25
  export const WebhookPayloadSchema = z.discriminatedUnion('eventName', [
38
26
  TaskAddedPayloadSchema,
@@ -46,6 +34,19 @@ export const WebhookPayloadSchema = z.discriminatedUnion('eventName', [
46
34
  LabelAddedPayloadSchema,
47
35
  LabelUpdatedPayloadSchema,
48
36
  LabelDeletedPayloadSchema,
49
- UntypedWebhookPayloadSchema,
37
+ ProjectAddedPayloadSchema,
38
+ ProjectUpdatedPayloadSchema,
39
+ ProjectDeletedPayloadSchema,
40
+ ProjectArchivedPayloadSchema,
41
+ ProjectUnarchivedPayloadSchema,
42
+ SectionAddedPayloadSchema,
43
+ SectionUpdatedPayloadSchema,
44
+ SectionDeletedPayloadSchema,
45
+ SectionArchivedPayloadSchema,
46
+ SectionUnarchivedPayloadSchema,
47
+ FilterAddedPayloadSchema,
48
+ FilterUpdatedPayloadSchema,
49
+ FilterDeletedPayloadSchema,
50
+ ReminderFiredPayloadSchema,
50
51
  ]);
51
52
  export { WebhookEventSchema };
@@ -1,4 +1,22 @@
1
1
  import { z } from 'zod';
2
+ /**
3
+ * Raw section fields (the persisted shape). Exposed so schemas that extend
4
+ * or override a field — notably the webhook variant — can reuse the base
5
+ * without duplicating every field.
6
+ */
7
+ export declare const SectionBaseSchema: z.ZodObject<{
8
+ id: z.ZodString;
9
+ userId: z.ZodString;
10
+ projectId: z.ZodString;
11
+ addedAt: z.ZodCoercedDate<unknown>;
12
+ updatedAt: z.ZodCoercedDate<unknown>;
13
+ archivedAt: z.ZodNullable<z.ZodCoercedDate<unknown>>;
14
+ name: z.ZodString;
15
+ sectionOrder: z.ZodNumber;
16
+ isArchived: z.ZodBoolean;
17
+ isDeleted: z.ZodBoolean;
18
+ isCollapsed: z.ZodBoolean;
19
+ }, z.core.$strip>;
2
20
  export declare const SectionSchema: z.ZodPipe<z.ZodObject<{
3
21
  id: z.ZodString;
4
22
  userId: z.ZodString;
@@ -0,0 +1,96 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Enum-like object of filter (`filter:*`) webhook event names. Single
4
+ * source of truth for the discriminator values — `FILTER_WEBHOOK_EVENTS`
5
+ * and every `z.literal()` below derive from it.
6
+ */
7
+ export declare const FilterWebhookEventEnum: {
8
+ readonly Added: "filter:added";
9
+ readonly Updated: "filter:updated";
10
+ readonly Deleted: "filter:deleted";
11
+ };
12
+ /** Webhook events that carry a filter as their `eventData`. */
13
+ export declare const FILTER_WEBHOOK_EVENTS: readonly ["filter:added", "filter:updated", "filter:deleted"];
14
+ /**
15
+ * Webhook filter payloads match the shared {@link Filter} resource shape,
16
+ * so `eventData` reuses `FilterSchema` directly — no webhook-specific
17
+ * schema is needed.
18
+ */
19
+ export declare const FilterAddedPayloadSchema: z.ZodObject<{
20
+ eventName: z.ZodLiteral<"filter:added">;
21
+ eventData: z.ZodObject<{
22
+ id: z.ZodString;
23
+ name: z.ZodString;
24
+ query: z.ZodString;
25
+ color: z.ZodString;
26
+ isDeleted: z.ZodBoolean;
27
+ isFavorite: z.ZodBoolean;
28
+ isFrozen: z.ZodBoolean;
29
+ itemOrder: z.ZodNumber;
30
+ }, z.core.$loose>;
31
+ version: z.ZodEnum<{
32
+ 1: "1";
33
+ }>;
34
+ userId: z.ZodString;
35
+ initiator: z.ZodObject<{
36
+ id: z.ZodString;
37
+ fullName: z.ZodString;
38
+ email: z.ZodString;
39
+ imageId: z.ZodNullable<z.ZodString>;
40
+ isPremium: z.ZodBoolean;
41
+ }, z.core.$strip>;
42
+ triggeredAt: z.ZodCoercedDate<unknown>;
43
+ }, z.core.$strip>;
44
+ export type FilterAddedPayload = z.infer<typeof FilterAddedPayloadSchema>;
45
+ export declare const FilterUpdatedPayloadSchema: z.ZodObject<{
46
+ eventName: z.ZodLiteral<"filter:updated">;
47
+ eventData: z.ZodObject<{
48
+ id: z.ZodString;
49
+ name: z.ZodString;
50
+ query: z.ZodString;
51
+ color: z.ZodString;
52
+ isDeleted: z.ZodBoolean;
53
+ isFavorite: z.ZodBoolean;
54
+ isFrozen: z.ZodBoolean;
55
+ itemOrder: z.ZodNumber;
56
+ }, z.core.$loose>;
57
+ version: z.ZodEnum<{
58
+ 1: "1";
59
+ }>;
60
+ userId: z.ZodString;
61
+ initiator: z.ZodObject<{
62
+ id: z.ZodString;
63
+ fullName: z.ZodString;
64
+ email: z.ZodString;
65
+ imageId: z.ZodNullable<z.ZodString>;
66
+ isPremium: z.ZodBoolean;
67
+ }, z.core.$strip>;
68
+ triggeredAt: z.ZodCoercedDate<unknown>;
69
+ }, z.core.$strip>;
70
+ export type FilterUpdatedPayload = z.infer<typeof FilterUpdatedPayloadSchema>;
71
+ export declare const FilterDeletedPayloadSchema: z.ZodObject<{
72
+ eventName: z.ZodLiteral<"filter:deleted">;
73
+ eventData: z.ZodObject<{
74
+ id: z.ZodString;
75
+ name: z.ZodString;
76
+ query: z.ZodString;
77
+ color: z.ZodString;
78
+ isDeleted: z.ZodBoolean;
79
+ isFavorite: z.ZodBoolean;
80
+ isFrozen: z.ZodBoolean;
81
+ itemOrder: z.ZodNumber;
82
+ }, z.core.$loose>;
83
+ version: z.ZodEnum<{
84
+ 1: "1";
85
+ }>;
86
+ userId: z.ZodString;
87
+ initiator: z.ZodObject<{
88
+ id: z.ZodString;
89
+ fullName: z.ZodString;
90
+ email: z.ZodString;
91
+ imageId: z.ZodNullable<z.ZodString>;
92
+ isPremium: z.ZodBoolean;
93
+ }, z.core.$strip>;
94
+ triggeredAt: z.ZodCoercedDate<unknown>;
95
+ }, z.core.$strip>;
96
+ export type FilterDeletedPayload = z.infer<typeof FilterDeletedPayloadSchema>;
@@ -1,5 +1,9 @@
1
1
  export * from './comments.js';
2
2
  export * from './envelope.js';
3
+ export * from './filters.js';
3
4
  export * from './labels.js';
5
+ export * from './projects.js';
6
+ export * from './reminders.js';
7
+ export * from './sections.js';
4
8
  export * from './tasks.js';
5
9
  export * from './types.js';