From 0df8a632b760276329e2a8055e2ff356b3f0f5c9 Mon Sep 17 00:00:00 2001 From: Mostafa Rashed <17770919+mrashed-dev@users.noreply.github.com> Date: Thu, 22 Feb 2024 16:45:09 -0500 Subject: [PATCH 1/5] TW-2563 Add support for roundTo field --- CHANGELOG.md | 4 ++++ src/models/availability.ts | 15 ++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b3739c4a..68e9bc31 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +### Unreleased +* Added support for `roundTo` field in availability response +* + ### 7.1.0 / 2024-02-12 * Added support for `/v3/connect/tokeninfo` endpoint * Models can now directly be imported from the top-level `nylas` package diff --git a/src/models/availability.ts b/src/models/availability.ts index 1253730b..e2215b10 100644 --- a/src/models/availability.ts +++ b/src/models/availability.ts @@ -39,15 +39,24 @@ export interface GetAvailabilityRequest { * If you have a meeting starting at 9:59, the API returns times starting at 10:00. 10:00-10:30, 10:15-10:45. */ intervalMinutes?: number; + /** - * When set to true, the availability time slots will start at 30 minutes past or on the hour. - * For example, a free slot starting at 16:10 is considered available only from 16:30. + * The number of minutes to round the time slots to. + * This allows for rounding to any multiple of 5 minutes, up to a maximum of 60 minutes. + * The default value is set to 15 minutes. + * When this variable is assigned a value, it overrides the behavior of the {@link roundTo30Minutes} flag, if it was set. */ - roundTo30Minutes?: boolean; + roundTo?: number; /** * The rules to apply when checking availability. */ availabilityRules?: AvailabilityRules; + /** + * When set to true, the availability time slots will start at 30 minutes past or on the hour. + * For example, a free slot starting at 16:10 is considered available only from 16:30. + * @deprecated Use [roundTo] instead. + */ + roundTo30Minutes?: boolean; } /** From bce125ecfe11bdd52dfeceabaf3813cb7a8ecbe1 Mon Sep 17 00:00:00 2001 From: Mostafa Rashed <17770919+mrashed-dev@users.noreply.github.com> Date: Thu, 22 Feb 2024 16:57:54 -0500 Subject: [PATCH 2/5] TW-2673 Added support for `attributes` field --- CHANGELOG.md | 4 ++-- src/models/folders.ts | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 68e9bc31..878f4103 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,8 @@ # Changelog ### Unreleased -* Added support for `roundTo` field in availability response -* +* Added support for `roundTo` field in availability response model +* Added support for `attributes` field in folder model ### 7.1.0 / 2024-02-12 * Added support for `/v3/connect/tokeninfo` endpoint diff --git a/src/models/folders.ts b/src/models/folders.ts index 41e6ab10..04ced478 100644 --- a/src/models/folders.ts +++ b/src/models/folders.ts @@ -56,6 +56,14 @@ export interface Folder { * The number of unread items inside of a folder. */ unreadCount?: number; + + /** + * Common attribute descriptors shared by system folders across providers. + * For example, Sent email folders have the `["\\Sent"]` attribute. + * For IMAP grants, IMAP providers provide the attributes. + * For Google and Microsoft Graph, Nylas matches system folders to a set of common attributes. + */ + attributes?: string[]; } /** From 4d130ea307a94a0a9cdf31eafa45f0152957b5e9 Mon Sep 17 00:00:00 2001 From: Mostafa Rashed <17770919+mrashed-dev@users.noreply.github.com> Date: Thu, 22 Feb 2024 17:02:17 -0500 Subject: [PATCH 3/5] TW-2676 Added support for icloud auth provider --- CHANGELOG.md | 1 + src/models/auth.ts | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 878f4103..5008ab7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### Unreleased * Added support for `roundTo` field in availability response model * Added support for `attributes` field in folder model +* Added support for icloud as an auth provider ### 7.1.0 / 2024-02-12 * Added support for `/v3/connect/tokeninfo` endpoint diff --git a/src/models/auth.ts b/src/models/auth.ts index 3af8741c..34436854 100644 --- a/src/models/auth.ts +++ b/src/models/auth.ts @@ -6,7 +6,12 @@ type AccessType = 'online' | 'offline'; /** * Type for the different OAuth providers Nylas supports. */ -export type Provider = 'google' | 'imap' | 'microsoft' | 'virtual-calendar'; +export type Provider = + | 'google' + | 'imap' + | 'microsoft' + | 'icloud' + | 'virtual-calendar'; /** * Configuration for generating a URL for OAuth 2.0 authentication. From 5e55c27ec99cbf640bdf3f5f9dff54b4b9734239 Mon Sep 17 00:00:00 2001 From: Mostafa Rashed <17770919+mrashed-dev@users.noreply.github.com> Date: Thu, 22 Feb 2024 17:20:38 -0500 Subject: [PATCH 4/5] TW-2664 remove client ID --- CHANGELOG.md | 1 + src/models/auth.ts | 4 ---- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5008ab7d..4dd14169 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * Added support for `roundTo` field in availability response model * Added support for `attributes` field in folder model * Added support for icloud as an auth provider +* Removed unnecessary `clientId` from detectProvider params ### 7.1.0 / 2024-02-12 * Added support for `/v3/connect/tokeninfo` endpoint diff --git a/src/models/auth.ts b/src/models/auth.ts index 34436854..c3ce686d 100644 --- a/src/models/auth.ts +++ b/src/models/auth.ts @@ -180,10 +180,6 @@ export interface ProviderDetectParams { * Email address to detect the provider for. */ email: string; - /** - * Client ID of the Nylas application. - */ - clientId: string; /** * Search by all providers regardless of created integrations. If unset, defaults to false. */ From 261baf28dded5415e73aa5f038ea6feecc400117 Mon Sep 17 00:00:00 2001 From: Mostafa Rashed <17770919+mrashed-dev@users.noreply.github.com> Date: Thu, 22 Feb 2024 17:39:31 -0500 Subject: [PATCH 5/5] tests --- tests/resources/auth.spec.ts | 1 - tests/resources/folders.spec.ts | 36 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/tests/resources/auth.spec.ts b/tests/resources/auth.spec.ts index 6294d8ed..7725aa07 100644 --- a/tests/resources/auth.spec.ts +++ b/tests/resources/auth.spec.ts @@ -247,7 +247,6 @@ describe('Auth', () => { it('should call apiClient.request with the correct params', async () => { await auth.detectProvider({ email: 'email@example.com', - clientId: 'testClientId', allProviderTypes: true, }); }); diff --git a/tests/resources/folders.spec.ts b/tests/resources/folders.spec.ts index 017802af..a429bd53 100644 --- a/tests/resources/folders.spec.ts +++ b/tests/resources/folders.spec.ts @@ -1,5 +1,6 @@ import APIClient from '../../src/apiClient'; import { Folders } from '../../src/resources/folders'; +import { objKeysToCamelCase } from '../../src/utils'; jest.mock('../../src/apiClient'); describe('Folders', () => { @@ -17,6 +18,41 @@ describe('Folders', () => { apiClient.request.mockResolvedValue({}); }); + describe('deserializing', () => { + it('should return a folder object as expected', () => { + const apiFolder = { + id: 'SENT', + grant_id: '41009df5-bf11-4c97-aa18-b285b5f2e386', + name: 'SENT', + system_folder: true, + object: 'folder', + unread_count: 0, + child_count: 0, + parent_id: 'ascsf21412', + background_color: '#039BE5', + text_color: '#039BE5', + total_count: 0, + attributes: ['\\SENT'], + }; + + const folder = objKeysToCamelCase(apiFolder); + expect(folder).toEqual({ + id: 'SENT', + grantId: '41009df5-bf11-4c97-aa18-b285b5f2e386', + name: 'SENT', + systemFolder: true, + object: 'folder', + unreadCount: 0, + childCount: 0, + parentId: 'ascsf21412', + backgroundColor: '#039BE5', + textColor: '#039BE5', + totalCount: 0, + attributes: ['\\SENT'], + }); + }); + }); + describe('list', () => { it('should call apiClient.request with the correct params', async () => { await folders.list({