From 2b5ea495d89bc7023f3dbdbb5be61c7242da0b27 Mon Sep 17 00:00:00 2001 From: Mostafa Rashed <17770919+mrashed-dev@users.noreply.github.com> Date: Wed, 7 Feb 2024 23:46:29 +0400 Subject: [PATCH 1/3] TW-2534 createdAt and updatedAt are optional --- src/models/events.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/models/events.ts b/src/models/events.ts index 34aaf76e..69530927 100644 --- a/src/models/events.ts +++ b/src/models/events.ts @@ -29,14 +29,6 @@ export interface Event { * If the event participants are able to edit the event. */ readOnly: boolean; - /** - * Unix timestamp when the event was created. - */ - createdAt: number; - /** - * Unix timestamp when the event was last updated. - */ - updatedAt: number; /** * List of participants invited to the event. Participants may also be rooms or resources. */ @@ -110,6 +102,14 @@ export interface Event { * Status of the event. */ status?: Status; + /** + * Unix timestamp when the event was created. + */ + createdAt?: number; + /** + * Unix timestamp when the event was last updated. + */ + updatedAt?: number; } /** From 4b260d7119fc019413b6386fdb9223fffcccae9f Mon Sep 17 00:00:00 2001 From: Mostafa Rashed <17770919+mrashed-dev@users.noreply.github.com> Date: Thu, 8 Feb 2024 00:21:54 +0400 Subject: [PATCH 2/3] TW-2541 Fix webhook schema --- src/models/webhooks.ts | 15 ++++++++++----- tests/resources/webhooks.spec.ts | 8 ++++---- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/models/webhooks.ts b/src/models/webhooks.ts index 72d633f3..ab85619a 100644 --- a/src/models/webhooks.ts +++ b/src/models/webhooks.ts @@ -13,11 +13,11 @@ export interface Webhook { /** * The url to send webhooks to. */ - callbackUrl: string; + webhookUrl: string; /** * The status of the new destination. */ - status: 'active' | 'failing' | 'failed' | 'pause'; + status: WebhookStatus; /** * The time the status field was last updated, represented as a Unix timestamp in seconds. */ @@ -37,7 +37,7 @@ export interface Webhook { /** * The email addresses that Nylas notifies when a webhook is down for a while. */ - notificationEmailAddress?: string; + notificationEmailAddresses?: string[]; } /** @@ -94,7 +94,7 @@ export interface CreateWebhookRequest { /** * The url to send webhooks to. */ - callbackUrl: string; + webhookUrl: string; /** * A human-readable description of the webhook destination. */ @@ -102,7 +102,7 @@ export interface CreateWebhookRequest { /** * The email addresses that Nylas notifies when a webhook is down for a while. */ - notificationEmailAddress?: string; + notificationEmailAddresses?: string[]; } /** @@ -127,3 +127,8 @@ export enum WebhookTriggers { MessageSendSuccess = 'message.send_success', MessageSendFailed = 'message.send_failed', } + +/** + * Enum representing the available webhook statuses. + */ +export type WebhookStatus = 'active' | 'failing' | 'failed' | 'pause'; diff --git a/tests/resources/webhooks.spec.ts b/tests/resources/webhooks.spec.ts index c2ebe33f..8a28e05c 100644 --- a/tests/resources/webhooks.spec.ts +++ b/tests/resources/webhooks.spec.ts @@ -70,9 +70,9 @@ describe('Webhooks', () => { await webhooks.create({ requestBody: { triggerTypes: [WebhookTriggers.CalendarCreated], - callbackUrl: 'https://test.callback.com', + webhookUrl: 'https://test.callback.com', description: "My Webhook's Description", - notificationEmailAddress: 'notification@example.com', + notificationEmailAddresses: ['notification@example.com'], }, overrides: { apiUri: 'https://test.api.nylas.com', @@ -84,9 +84,9 @@ describe('Webhooks', () => { path: '/v3/webhooks', body: { triggerTypes: [WebhookTriggers.CalendarCreated], - callbackUrl: 'https://test.callback.com', + webhookUrl: 'https://test.callback.com', description: "My Webhook's Description", - notificationEmailAddress: 'notification@example.com', + notificationEmailAddresses: ['notification@example.com'], }, overrides: { apiUri: 'https://test.api.nylas.com', From f5239b92d43c1860b997bdb17099d0d45a8c8360 Mon Sep 17 00:00:00 2001 From: Mostafa Rashed <17770919+mrashed-dev@users.noreply.github.com> Date: Thu, 8 Feb 2024 00:26:53 +0400 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 594b7af7..148d719e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ### Unreleased * Models can now directly be imported from the top-level `nylas` package +* Fixed inaccuracies in event and webhook models ### 7.0.0 / 2024-02-05 * **BREAKING CHANGE**: Node SDK v7 supports the Nylas API v3 exclusively, dropping support for any endpoints that are not available in v3.