From 1c38ecb13c81f4739beb12d9cd7a7bdff76ccd39 Mon Sep 17 00:00:00 2001
From: Mostafa Rashed <17770919+mrashed-dev@users.noreply.github.com>
Date: Wed, 18 Oct 2023 13:15:53 -0400
Subject: [PATCH 01/11] export interfaces
---
src/resources/calendars.ts | 14 +++++++-------
src/resources/events.ts | 10 +++++-----
src/resources/grants.ts | 8 ++++----
src/resources/redirectUris.ts | 8 ++++----
src/resources/webhooks.ts | 8 ++++----
5 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/src/resources/calendars.ts b/src/resources/calendars.ts
index 5d4b980b..d53e4f42 100644
--- a/src/resources/calendars.ts
+++ b/src/resources/calendars.ts
@@ -22,7 +22,7 @@ import { GetFreeBusyRequest, GetFreeBusyResponse } from '../models/freeBusy.js';
* @property calendarId The id of the Calendar to retrieve. Use "primary" to refer to the primary calendar associated with grant.
* @property identifier The identifier of the grant to act upon
*/
-interface FindCalendarParams {
+export interface FindCalendarParams {
identifier: string;
calendarId: string;
}
@@ -32,7 +32,7 @@ interface FindCalendarParams {
* @property identifier The identifier of the grant to act upon
* @property queryParams The query parameters to include in the request
*/
-interface ListCalendersParams {
+export interface ListCalendersParams {
identifier: string;
queryParams?: ListCalendersQueryParams;
}
@@ -42,7 +42,7 @@ interface ListCalendersParams {
* @property identifier The identifier of the grant to act upon
* @property requestBody The request body to create a calendar
*/
-interface CreateCalendarParams {
+export interface CreateCalendarParams {
identifier: string;
requestBody: CreateCalenderRequest;
}
@@ -52,7 +52,7 @@ interface CreateCalendarParams {
* @property identifier The identifier of the grant to act upon
* @property calendarId The id of the Calendar to retrieve. Use "primary" to refer to the primary calendar associated with grant.
*/
-interface UpdateCalendarParams {
+export interface UpdateCalendarParams {
identifier: string;
calendarId: string;
requestBody: UpdateCalenderRequest;
@@ -63,7 +63,7 @@ interface UpdateCalendarParams {
* @property identifier The identifier of the grant to act upon
* @property calendarId The id of the Calendar to retrieve. Use "primary" to refer to the primary calendar associated with grant.
*/
-interface DestroyCalendarParams {
+export interface DestroyCalendarParams {
identifier: string;
calendarId: string;
}
@@ -72,7 +72,7 @@ interface DestroyCalendarParams {
* The parameters for the {@link Calendars.getAvailability} method
* @property requestBody The availability request
*/
-interface GetAvailabilityParams {
+export interface GetAvailabilityParams {
requestBody: GetAvailabilityRequest;
}
@@ -81,7 +81,7 @@ interface GetAvailabilityParams {
* @property identifier The identifier of the grant to act upon
* @property requestBody The free busy request
*/
-interface GetFreeBusyParams {
+export interface GetFreeBusyParams {
identifier: string;
requestBody: GetFreeBusyRequest;
}
diff --git a/src/resources/events.ts b/src/resources/events.ts
index 05efcd5b..295b0867 100644
--- a/src/resources/events.ts
+++ b/src/resources/events.ts
@@ -21,7 +21,7 @@ import { AsyncListResponse, Resource } from './resource.js';
* @property identifier The identifier of the grant to act upon
* @property queryParams The query parameters to include in the request
*/
-interface FindEventParams {
+export interface FindEventParams {
identifier: string;
eventId: string;
queryParams: FindEventQueryParams;
@@ -31,7 +31,7 @@ interface FindEventParams {
* @property identifier The identifier of the grant to act upon
* @property queryParams The query parameters to include in the request
*/
-interface ListEventParams {
+export interface ListEventParams {
identifier: string;
queryParams: ListEventQueryParams;
}
@@ -41,7 +41,7 @@ interface ListEventParams {
* @property queryParams The query parameters to include in the request
* @property requestBody The values to create the Event with
*/
-interface CreateEventParams {
+export interface CreateEventParams {
identifier: string;
requestBody: CreateEventRequest;
queryParams: CreateEventQueryParams;
@@ -53,7 +53,7 @@ interface CreateEventParams {
* @property requestBody The values to update the Event with
* @property queryParams The query parameters to include in the request
*/
-interface UpdateEventParams {
+export interface UpdateEventParams {
identifier: string;
eventId: string;
requestBody: UpdateEventRequest;
@@ -65,7 +65,7 @@ interface UpdateEventParams {
* @property eventId The id of the Event to retrieve.
* @property queryParams The query parameters to include in the request
*/
-interface DestroyEventParams {
+export interface DestroyEventParams {
identifier: string;
eventId: string;
queryParams: DestroyEventQueryParams;
diff --git a/src/resources/grants.ts b/src/resources/grants.ts
index 685b803a..b8fc5b6a 100644
--- a/src/resources/grants.ts
+++ b/src/resources/grants.ts
@@ -15,14 +15,14 @@ import {
/**
* @property grantId The id of the Grant to retrieve.
*/
-interface FindGrantParams {
+export interface FindGrantParams {
grantId: string;
}
/**
* @property requestBody The values to create the Grant with.
*/
-interface CreateGrantParams {
+export interface CreateGrantParams {
requestBody: CreateGrantRequest;
}
@@ -30,7 +30,7 @@ interface CreateGrantParams {
* @property grantId The id of the Grant to update.
* @property requestBody The values to update the Grant with.
*/
-interface UpdateGrantParams {
+export interface UpdateGrantParams {
grantId: string;
requestBody: UpdateGrantRequest;
}
@@ -38,7 +38,7 @@ interface UpdateGrantParams {
/**
* @property grantId The id of the Grant to delete.
*/
-interface DestroyGrantParams {
+export interface DestroyGrantParams {
grantId: string;
}
diff --git a/src/resources/redirectUris.ts b/src/resources/redirectUris.ts
index 5839cb91..3200d36a 100644
--- a/src/resources/redirectUris.ts
+++ b/src/resources/redirectUris.ts
@@ -14,14 +14,14 @@ import { Overrides } from '../config.js';
/**
* @property redirectUriId The id of the Redirect URI to retrieve.
*/
-interface FindRedirectUrisParams {
+export interface FindRedirectUrisParams {
redirectUriId: string;
}
/**
* @property requestBody The values to create the Redirect URI with.
*/
-interface CreateRedirectUrisParams {
+export interface CreateRedirectUrisParams {
requestBody: CreateRedirectUriRequest;
}
@@ -29,7 +29,7 @@ interface CreateRedirectUrisParams {
* @property redirectUriId The id of the Redirect URI to update.
* @property requestBody The values to update the Redirect URI with.
*/
-interface UpdateRedirectUrisParams {
+export interface UpdateRedirectUrisParams {
redirectUriId: string;
requestBody: UpdateRedirectUriRequest;
}
@@ -37,7 +37,7 @@ interface UpdateRedirectUrisParams {
/**
* @property redirectUriId The id of the Redirect URI to delete.
*/
-interface DestroyRedirectUrisParams {
+export interface DestroyRedirectUrisParams {
redirectUriId: string;
}
diff --git a/src/resources/webhooks.ts b/src/resources/webhooks.ts
index 1c0dc286..61f84029 100644
--- a/src/resources/webhooks.ts
+++ b/src/resources/webhooks.ts
@@ -13,14 +13,14 @@ import {
/**
* @property webhookId The ID of the webhook destination to update
*/
-interface FindWebhookParams {
+export interface FindWebhookParams {
webhookId: string;
}
/**
* @property requestBody The webhook destination details
*/
-interface CreateWebhookParams {
+export interface CreateWebhookParams {
requestBody: CreateWebhookRequest;
}
@@ -28,7 +28,7 @@ interface CreateWebhookParams {
* @property webhookId The ID of the webhook destination to update
* @property requestBody The updated webview destination details
*/
-interface UpdateWebhookParams {
+export interface UpdateWebhookParams {
webhookId: string;
requestBody: UpdateWebhookRequest;
}
@@ -36,7 +36,7 @@ interface UpdateWebhookParams {
/**
* @property webhookId The ID of the webhook destination to delete
*/
-interface DestroyWebhookParams {
+export interface DestroyWebhookParams {
webhookId: string;
}
From 095cbe9945feca22e36517678db922484d899bf5 Mon Sep 17 00:00:00 2001
From: Mostafa Rashed <17770919+mrashed-dev@users.noreply.github.com>
Date: Wed, 18 Oct 2023 13:16:05 -0400
Subject: [PATCH 02/11] fix event models
---
src/models/events.ts | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/models/events.ts b/src/models/events.ts
index 7c7069df..c406876b 100644
--- a/src/models/events.ts
+++ b/src/models/events.ts
@@ -92,7 +92,7 @@ export interface Event {
/**
* Organizer of the event.
*/
- organizer: EmailName;
+ organizer?: EmailName;
/**
* An list of RRULE and EXDATE strings.
* @see RFC-5545
@@ -205,7 +205,6 @@ export interface ListEventQueryParams extends ListQueryParams {
* Different providers have different semantics for cancelled events.
*/
showCancelled?: boolean;
- eventId?: string;
/**
* Specify calendar ID of the event. "primary" is a supported value indicating the user's primary calendar.
*/
From 7a59c32cd7f5abc64fb11092a0db6fa6aca322bc Mon Sep 17 00:00:00 2001
From: Mostafa Rashed <17770919+mrashed-dev@users.noreply.github.com>
Date: Wed, 18 Oct 2023 13:16:17 -0400
Subject: [PATCH 03/11] wrap response around NylasResponse
---
src/resources/auth.ts | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/resources/auth.ts b/src/resources/auth.ts
index 824880ad..c8f8a127 100644
--- a/src/resources/auth.ts
+++ b/src/resources/auth.ts
@@ -13,6 +13,7 @@ import {
ProviderDetectParams,
ProviderDetectResponse,
} from '../models/auth.js';
+import { NylasResponse } from '../models/response';
/**
* A collection of authentication related API endpoints
@@ -141,8 +142,8 @@ export class Auth extends Resource {
*/
public async detectProvider(
params: ProviderDetectParams
- ): Promise {
- return this.apiClient.request({
+ ): Promise> {
+ return this.apiClient.request>({
method: 'POST',
path: `/v3/grants/providers/detect`,
queryParams: params,
From a4a0eeea4753788982fd48f41601e3218b55bc77 Mon Sep 17 00:00:00 2001
From: Mostafa Rashed <17770919+mrashed-dev@users.noreply.github.com>
Date: Tue, 30 Jan 2024 23:50:53 +0400
Subject: [PATCH 04/11] fix types in drafts
---
src/resources/drafts.ts | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/resources/drafts.ts b/src/resources/drafts.ts
index 75022a97..e98aa7ed 100644
--- a/src/resources/drafts.ts
+++ b/src/resources/drafts.ts
@@ -12,6 +12,7 @@ import {
NylasResponse,
} from '../models/response.js';
import { Messages } from './messages.js';
+import { Message } from '../models/messages';
/**
* The parameters for the {@link Drafts.list} method
@@ -160,13 +161,13 @@ export class Drafts extends Resource {
/**
* Send a Draft
- * @return The sent draft
+ * @return The sent message
*/
public send({
identifier,
draftId,
overrides,
- }: SendDraftParams & Overrides): Promise> {
+ }: SendDraftParams & Overrides): Promise> {
return super._create({
path: `/v3/grants/${identifier}/drafts/${draftId}`,
requestBody: {},
From 406e3b7d83ae63bbdae6b47b8cabef0007542452 Mon Sep 17 00:00:00 2001
From: Mostafa Rashed <17770919+mrashed-dev@users.noreply.github.com>
Date: Tue, 30 Jan 2024 23:53:08 +0400
Subject: [PATCH 05/11] lint
---
src/resources/drafts.ts | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/resources/drafts.ts b/src/resources/drafts.ts
index e98aa7ed..f16e5fb0 100644
--- a/src/resources/drafts.ts
+++ b/src/resources/drafts.ts
@@ -1,3 +1,5 @@
+import { Overrides } from '../config.js';
+import { Messages } from './messages.js';
import { AsyncListResponse, Resource } from './resource.js';
import {
CreateDraftRequest,
@@ -5,14 +7,12 @@ import {
ListDraftsQueryParams,
UpdateDraftRequest,
} from '../models/drafts.js';
-import { Overrides } from '../config.js';
+import { Message } from '../models/messages.js';
import {
NylasBaseResponse,
NylasListResponse,
NylasResponse,
} from '../models/response.js';
-import { Messages } from './messages.js';
-import { Message } from '../models/messages';
/**
* The parameters for the {@link Drafts.list} method
From 8371d2ba13c96ee9ed46fc1460b0b923ebcf23cd Mon Sep 17 00:00:00 2001
From: Mostafa Rashed <17770919+mrashed-dev@users.noreply.github.com>
Date: Wed, 31 Jan 2024 21:45:44 +0400
Subject: [PATCH 06/11] fix creat draft & send message model
---
src/models/drafts.ts | 7 ++++++-
src/models/messages.ts | 28 ++++++++++++++--------------
2 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/src/models/drafts.ts b/src/models/drafts.ts
index a1620b4e..70d51109 100644
--- a/src/models/drafts.ts
+++ b/src/models/drafts.ts
@@ -45,7 +45,12 @@ export interface Draft
/**
* Interface representing a request to update a draft.
*/
-export type UpdateDraftRequest = Partial;
+export type UpdateDraftRequest = Partial & {
+ /**
+ * Return drafts that are unread.
+ */
+ unread?: boolean;
+};
/**
* Interface representing the different tracking options for when a message is sent.
diff --git a/src/models/messages.ts b/src/models/messages.ts
index 91b29919..e992957f 100644
--- a/src/models/messages.ts
+++ b/src/models/messages.ts
@@ -26,20 +26,10 @@ export interface BaseCreateMessage {
* An array of files to attach to the message.
*/
attachments?: CreateFileRequest[];
- /**
- * A short snippet of the message body.
- * This is the first 100 characters of the message body, with any HTML tags removed.
- */
- snippet?: string;
/**
* The message subject.
*/
subject?: string;
- /**
- * A reference to the parent thread object.
- * If this is a new draft, the thread will be empty.
- */
- threadId?: string;
/**
* The full HTML message body.
* Messages with only plain-text representations are up-converted to HTML.
@@ -49,10 +39,6 @@ export interface BaseCreateMessage {
* Whether or not the message has been starred by the user.
*/
starred?: boolean;
- /**
- * Whether or not the message has been read by the user.
- */
- unread?: boolean;
}
/**
@@ -88,6 +74,20 @@ export interface BaseMessage extends Omit {
* An array of files attached to the message.
*/
attachments?: File[];
+ /**
+ * A short snippet of the message body.
+ * This is the first 100 characters of the message body, with any HTML tags removed.
+ */
+ snippet?: string;
+ /**
+ * A reference to the parent thread object.
+ * If this is a new draft, the thread will be empty.
+ */
+ threadId?: string;
+ /**
+ * Whether or not the message has been read by the user.
+ */
+ unread?: boolean;
}
/**
From 8643a743b2f2c4cebbf8f2a79b7f5f1c06e0d22c Mon Sep 17 00:00:00 2001
From: Mostafa Rashed <17770919+mrashed-dev@users.noreply.github.com>
Date: Thu, 1 Feb 2024 23:14:01 +0400
Subject: [PATCH 07/11] AV-3203 Fix reminders field
---
src/models/events.ts | 30 ++++++++++++++++++++----------
1 file changed, 20 insertions(+), 10 deletions(-)
diff --git a/src/models/events.ts b/src/models/events.ts
index 5a65db32..5854f9a7 100644
--- a/src/models/events.ts
+++ b/src/models/events.ts
@@ -99,9 +99,9 @@ export interface Event {
*/
recurrence?: string[];
/**
- * List of reminders for the event.
+ * A list of reminders to send for the event. If left empty or omitted, the event uses the provider defaults.
*/
- reminders?: Reminder[];
+ reminders?: Reminders;
/**
* Status of the event.
*/
@@ -147,14 +147,9 @@ export interface CreateEventRequest {
*/
conferencing?: Conferencing;
/**
- * The number of minutes before the event start time when a user wants a reminder for this event.
- * Reminder minutes need to be entered in the following format: "[20]".
- */
- reminderMinutes?: string;
- /**
- * Method to remind the user about the event. (Google only).
+ * A list of reminders to send for the event. If left empty or omitted, the event uses the provider defaults.
*/
- reminderMethod?: string;
+ reminders?: Reminders;
/**
* A list of key-value pairs storing additional data.
*/
@@ -548,7 +543,22 @@ export interface Participant {
/**
* Interface representing the reminders field of an event.
*/
-export interface Reminder {
+export interface Reminders {
+ /**
+ * Whether to use the default reminders for the calendar.
+ * When true, uses the default reminder settings for the calendar
+ */
+ useDefault: boolean;
+ /**
+ * A list of reminders for the event if useDefault is set to false.
+ */
+ overrides: ReminderOverride[];
+}
+
+/**
+ * Interface representing the reminder details for an event.
+ */
+export interface ReminderOverride {
/**
* The number of minutes before the event start time when a user wants a reminder for this event.
* Reminder minutes are in the following format: "[20]".
From 710fc16470e8320e5d75a915b39b3c3c810e65a8 Mon Sep 17 00:00:00 2001
From: Mostafa Rashed <17770919+mrashed-dev@users.noreply.github.com>
Date: Thu, 1 Feb 2024 23:15:31 +0400
Subject: [PATCH 08/11] AV-3204 Remove ContactType enum
---
src/models/contacts.ts | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/src/models/contacts.ts b/src/models/contacts.ts
index 38a20a4b..fc2dc0cc 100644
--- a/src/models/contacts.ts
+++ b/src/models/contacts.ts
@@ -33,7 +33,6 @@ export interface Contact {
/**
* Custom Types.
*/
-export type ContactType = 'work' | 'home' | 'other';
export type SourceType = 'address_book' | 'inbox' | 'domain';
export type GroupType = 'user' | 'system' | 'other';
@@ -42,7 +41,7 @@ export type GroupType = 'user' | 'system' | 'other';
*/
export interface Email {
email?: string;
- type?: ContactType;
+ type?: string;
}
/**
@@ -58,7 +57,7 @@ export interface InstantMessagingAddress {
*/
export interface PhoneNumber {
number?: string;
- type?: ContactType;
+ type?: string;
}
/**
@@ -71,7 +70,7 @@ export interface PhysicalAddress {
postalCode?: string;
state?: string;
country?: string;
- type?: ContactType;
+ type?: string;
}
/**
@@ -79,7 +78,7 @@ export interface PhysicalAddress {
*/
export interface WebPage {
url?: string;
- type?: ContactType;
+ type?: string;
}
/**
From b3ea54dba2822d473f4ece6ae2d7edb34d04f9f9 Mon Sep 17 00:00:00 2001
From: Mostafa Rashed <17770919+mrashed-dev@users.noreply.github.com>
Date: Thu, 1 Feb 2024 23:16:38 +0400
Subject: [PATCH 09/11] add default event visibility value
---
src/models/events.ts | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/models/events.ts b/src/models/events.ts
index 5854f9a7..34aaf76e 100644
--- a/src/models/events.ts
+++ b/src/models/events.ts
@@ -55,6 +55,10 @@ export interface Event {
* - {@link Details}
*/
conferencing: Conferencing;
+ /**
+ * Visibility of the event, if the event is private or public.
+ */
+ visibility: Visibility;
/**
* Description of the event.
*/
@@ -106,10 +110,6 @@ export interface Event {
* Status of the event.
*/
status?: Status;
- /**
- * Visibility of the event, if the event is private or public.
- */
- visibility?: Visibility;
}
/**
@@ -318,7 +318,7 @@ type RsvpStatus = 'yes' | 'no' | 'maybe';
/**
* Enum representing the visibility of an event.
*/
-type Visibility = 'public' | 'private';
+type Visibility = 'default' | 'public' | 'private';
/**
* Enum representing the supported conferencing providers.
From 20dfc9fb8320e6a4603401dc081b465957ec33b9 Mon Sep 17 00:00:00 2001
From: Mostafa Rashed <17770919+mrashed-dev@users.noreply.github.com>
Date: Thu, 1 Feb 2024 23:24:01 +0400
Subject: [PATCH 10/11] AV-3205 Finish transition from file to attachment
---
src/models/attachments.ts | 49 ++++++++++++++++++++++++--------
src/models/files.ts | 17 -----------
src/models/messages.ts | 6 ++--
src/utils.ts | 6 ++--
tests/resources/drafts.spec.ts | 4 +--
tests/resources/messages.spec.ts | 4 +--
6 files changed, 48 insertions(+), 38 deletions(-)
delete mode 100644 src/models/files.ts
diff --git a/src/models/attachments.ts b/src/models/attachments.ts
index b8cf282e..0434b7d9 100644
--- a/src/models/attachments.ts
+++ b/src/models/attachments.ts
@@ -1,12 +1,7 @@
/**
* Interface of an attachment object from Nylas.
*/
-export interface Attachment {
- /**
- * A globally unique object identifier.
- */
- id: string;
-
+interface BaseAttachment {
/**
* Attachment's name.
*/
@@ -18,19 +13,49 @@ export interface Attachment {
contentType: string;
/**
- * Grant ID of the Nylas account.
+ * If it's an inline attachment.
*/
- grantId: string;
+ isInline?: boolean;
/**
- * If it's an inline attachment.
+ * Attachment's size in bytes.
*/
- isInline: boolean;
+ size?: number;
/**
- * Attachment's size in bytes.
+ * Content ID of the attachment.
+ */
+ contentId?: string;
+
+ /**
+ * Content disposition of the attachment.
+ */
+ contentDisposition?: string;
+}
+
+/**
+ * Interface of a create attachment request.
+ */
+export interface CreateAttachmentRequest extends BaseAttachment {
+ /**
+ * Content of the attachment.
+ */
+ content: NodeJS.ReadableStream;
+}
+
+/**
+ * Interface of an attachment object from Nylas.
+ */
+export interface Attachment extends BaseAttachment {
+ /**
+ * Attachment's ID.
+ */
+ id: string;
+
+ /**
+ * Grant ID of the Nylas account.
*/
- size: number;
+ grantId: string;
}
/**
diff --git a/src/models/files.ts b/src/models/files.ts
deleted file mode 100644
index 779e22f5..00000000
--- a/src/models/files.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-interface BaseFile {
- filename: string;
- contentType: string;
- size?: number;
- isInline?: boolean;
- contentId?: string;
- contentDisposition?: string;
-}
-
-export interface CreateFileRequest extends BaseFile {
- content: NodeJS.ReadableStream;
-}
-
-export interface File extends BaseFile {
- id: string;
- grantId: string;
-}
diff --git a/src/models/messages.ts b/src/models/messages.ts
index e992957f..a215000d 100644
--- a/src/models/messages.ts
+++ b/src/models/messages.ts
@@ -1,6 +1,6 @@
import { EmailName } from './events.js';
-import { CreateFileRequest, File } from './files.js';
import { ListQueryParams } from './listQueryParams.js';
+import { Attachment, CreateAttachmentRequest } from './attachments.js';
/**
* @internal Internal interface for creating a message.
@@ -25,7 +25,7 @@ export interface BaseCreateMessage {
/**
* An array of files to attach to the message.
*/
- attachments?: CreateFileRequest[];
+ attachments?: CreateAttachmentRequest[];
/**
* The message subject.
*/
@@ -73,7 +73,7 @@ export interface BaseMessage extends Omit {
/**
* An array of files attached to the message.
*/
- attachments?: File[];
+ attachments?: Attachment[];
/**
* A short snippet of the message body.
* This is the first 100 characters of the message body, with any HTML tags removed.
diff --git a/src/utils.ts b/src/utils.ts
index 2783e769..453f3ef2 100644
--- a/src/utils.ts
+++ b/src/utils.ts
@@ -1,10 +1,12 @@
import { camelCase, snakeCase } from 'change-case';
-import { CreateFileRequest } from './models/files.js';
import * as fs from 'fs';
import * as path from 'path';
import * as mime from 'mime-types';
+import { CreateAttachmentRequest } from './models/attachments.js';
-export function createFileRequestBuilder(filePath: string): CreateFileRequest {
+export function createFileRequestBuilder(
+ filePath: string
+): CreateAttachmentRequest {
const stats = fs.statSync(filePath);
const filename = path.basename(filePath);
const contentType = mime.lookup(filePath) || 'application/octet-stream';
diff --git a/tests/resources/drafts.spec.ts b/tests/resources/drafts.spec.ts
index 025689b9..8e997166 100644
--- a/tests/resources/drafts.spec.ts
+++ b/tests/resources/drafts.spec.ts
@@ -1,7 +1,7 @@
import APIClient from '../../src/apiClient';
import { Drafts } from '../../src/resources/drafts';
-import { CreateFileRequest } from '../../src/models/files';
import { createReadableStream, MockedFormData } from '../testUtils';
+import { CreateAttachmentRequest } from '../../src/models/attachments';
jest.mock('../src/apiClient');
// Mock the FormData constructor
@@ -103,7 +103,7 @@ describe('Drafts', () => {
subject: 'This is my test email',
};
const fileStream = createReadableStream('This is the text from file 1');
- const file1: CreateFileRequest = {
+ const file1: CreateAttachmentRequest = {
filename: 'file1.txt',
contentType: 'text/plain',
content: fileStream,
diff --git a/tests/resources/messages.spec.ts b/tests/resources/messages.spec.ts
index 31396846..4fec7d84 100644
--- a/tests/resources/messages.spec.ts
+++ b/tests/resources/messages.spec.ts
@@ -1,7 +1,7 @@
import APIClient from '../../src/apiClient';
import { Messages } from '../../src/resources/messages';
-import { CreateFileRequest } from '../../src/models/files';
import { createReadableStream, MockedFormData } from '../testUtils';
+import { CreateAttachmentRequest } from '../../src/models/attachments';
jest.mock('../src/apiClient');
// Mock the FormData constructor
@@ -153,7 +153,7 @@ describe('Messages', () => {
subject: 'This is my test email',
};
const fileStream = createReadableStream('This is the text from file 1');
- const file1: CreateFileRequest = {
+ const file1: CreateAttachmentRequest = {
filename: 'file1.txt',
contentType: 'text/plain',
content: fileStream,
From 88f05207a28be509d0a218c4f5817bc6c2070dfa Mon Sep 17 00:00:00 2001
From: Mostafa Rashed <17770919+mrashed-dev@users.noreply.github.com>
Date: Thu, 1 Feb 2024 23:28:42 +0400
Subject: [PATCH 11/11] Update CHANGELOG.md
---
CHANGELOG.md | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 405debac..112b6579 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,8 +1,13 @@
# Changelog
### Unreleased
+* Added `default` event visibility value
* Changed `clientSecret` to optional for token exchange methods; defaults to API Key now
-* Fix missing `type` field in `Event` model
+* Updated reminders field to match updated API schema
+* Updated all references to `File` to `Attachment` to match API schema
+* Fixes to the `Event` models
+* Fixes to drafts and sending messages
+* Removed `ContactType` enum as the API accepts any string
### 7.0.0-beta.4 / 2024-01-12
* **BREAKING CHANGE**: Moved grants API out of `Auth` to `NylasClient`