diff --git a/CHANGELOG.md b/CHANGELOG.md index 5115e5cb..c3a09ab8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Fixed +- Make `conferencing` property optional in `Event` model to handle events without conferencing details ([#678](https://github.com/nylas/nylas-nodejs/issues/678)) + ## [7.13.2] - 2025-10-01 ### Fixed diff --git a/src/models/events.ts b/src/models/events.ts index 4b834b37..d111707b 100644 --- a/src/models/events.ts +++ b/src/models/events.ts @@ -64,7 +64,7 @@ export interface Event { * - {@link Autocreate} * - {@link Details} */ - conferencing: Conferencing; + conferencing?: Conferencing; /** * Visibility of the event, if the event is private or public. */ diff --git a/tests/resources/events.spec.ts b/tests/resources/events.spec.ts index 55134df9..8c485c2f 100644 --- a/tests/resources/events.spec.ts +++ b/tests/resources/events.spec.ts @@ -486,4 +486,138 @@ describe('Events', () => { }); }); }); + + describe('Event model with optional conferencing', () => { + it('should handle events without conferencing property', async () => { + const eventWithoutConferencing = { + requestId: 'request123', + data: { + id: 'event123', + grantId: 'grant123', + object: 'event' as const, + calendarId: 'calendar123', + busy: false, + readOnly: false, + participants: [], + when: { + time: 1617235200, + timezone: 'America/New_York', + object: 'time' as const, + }, + visibility: 'default' as const, + title: 'Event without conferencing', + }, + }; + + apiClient.request.mockResolvedValue(eventWithoutConferencing); + + const result = await events.find({ + identifier: 'id123', + eventId: 'event123', + queryParams: { + calendarId: 'calendar123', + }, + }); + + expect(result.data.conferencing).toBeUndefined(); + expect(result.data.title).toBe('Event without conferencing'); + }); + + it('should handle events with conferencing property', async () => { + const eventWithConferencing = { + requestId: 'request123', + data: { + id: 'event123', + grantId: 'grant123', + object: 'event' as const, + calendarId: 'calendar123', + busy: false, + readOnly: false, + participants: [], + when: { + time: 1617235200, + timezone: 'America/New_York', + object: 'time' as const, + }, + conferencing: { + provider: 'Zoom Meeting' as const, + details: { + url: 'https://zoom.us/j/123456789', + meetingCode: '123456789', + }, + }, + visibility: 'default' as const, + title: 'Event with conferencing', + }, + }; + + apiClient.request.mockResolvedValue(eventWithConferencing); + + const result = await events.find({ + identifier: 'id123', + eventId: 'event456', + queryParams: { + calendarId: 'calendar123', + }, + }); + + expect(result.data.conferencing).toBeDefined(); + expect(result.data.conferencing?.provider).toBe('Zoom Meeting'); + expect(result.data.title).toBe('Event with conferencing'); + }); + + it('should create events without conferencing', async () => { + const eventResponse = { + requestId: 'request123', + data: { + id: 'event123', + grantId: 'grant123', + object: 'event' as const, + calendarId: 'calendar123', + busy: false, + readOnly: false, + participants: [], + when: { + time: 1617235200, + timezone: 'America/New_York', + object: 'time' as const, + }, + visibility: 'default' as const, + title: 'Simple event', + }, + }; + + apiClient.request.mockResolvedValue(eventResponse); + + const result = await events.create({ + identifier: 'id123', + requestBody: { + when: { + time: 1617235200, + timezone: 'America/New_York', + }, + title: 'Simple event', + }, + queryParams: { + calendarId: 'calendar123', + }, + }); + + expect(apiClient.request).toHaveBeenCalledWith({ + method: 'POST', + path: '/v3/grants/id123/events', + body: { + when: { + time: 1617235200, + timezone: 'America/New_York', + }, + title: 'Simple event', + }, + queryParams: { + calendarId: 'calendar123', + }, + }); + expect(result.data.conferencing).toBeUndefined(); + }); + }); });