Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pre-GA Minor Fixes #495

Merged
merged 12 commits into from
Feb 5, 2024
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
49 changes: 37 additions & 12 deletions src/models/attachments.ts
Original file line number Diff line number Diff line change
@@ -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.
*/
Expand All @@ -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;
}

/**
Expand Down
9 changes: 4 additions & 5 deletions src/models/contacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -42,7 +41,7 @@ export type GroupType = 'user' | 'system' | 'other';
*/
export interface Email {
email?: string;
type?: ContactType;
type?: string;
}

/**
Expand All @@ -58,7 +57,7 @@ export interface InstantMessagingAddress {
*/
export interface PhoneNumber {
number?: string;
type?: ContactType;
type?: string;
}

/**
Expand All @@ -71,15 +70,15 @@ export interface PhysicalAddress {
postalCode?: string;
state?: string;
country?: string;
type?: ContactType;
type?: string;
}

/**
* Interface for web pages in a contact.
*/
export interface WebPage {
url?: string;
type?: ContactType;
type?: string;
}

/**
Expand Down
7 changes: 6 additions & 1 deletion src/models/drafts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ export interface Draft
/**
* Interface representing a request to update a draft.
*/
export type UpdateDraftRequest = Partial<CreateDraftRequest>;
export type UpdateDraftRequest = Partial<CreateDraftRequest> & {
/**
* Return drafts that are unread.
*/
unread?: boolean;
};

/**
* Interface representing the different tracking options for when a message is sent.
Expand Down
43 changes: 26 additions & 17 deletions src/models/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -92,24 +96,20 @@ export interface Event {
/**
* Organizer of the event.
*/
organizer: EmailName;
organizer?: EmailName;
/**
* An list of RRULE and EXDATE strings.
* @see <a href="https://datatracker.ietf.org/doc/html/rfc5545#section-3.8.5">RFC-5545</a>
*/
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.
*/
status?: Status;
/**
* Visibility of the event, if the event is private or public.
*/
visibility?: Visibility;
}

/**
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -212,7 +207,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.
*/
Expand Down Expand Up @@ -324,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.
Expand Down Expand Up @@ -549,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]".
Expand Down
17 changes: 0 additions & 17 deletions src/models/files.ts

This file was deleted.

34 changes: 17 additions & 17 deletions src/models/messages.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -25,21 +25,11 @@ 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;
attachments?: CreateAttachmentRequest[];
/**
* 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.
Expand All @@ -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;
}

/**
Expand Down Expand Up @@ -87,7 +73,21 @@ export interface BaseMessage extends Omit<BaseCreateMessage, 'attachments'> {
/**
* 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.
*/
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;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/resources/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ export class Auth extends Resource {
*/
public async detectProvider(
params: ProviderDetectParams
): Promise<ProviderDetectResponse> {
return this.apiClient.request<ProviderDetectResponse>({
): Promise<NylasResponse<ProviderDetectResponse>> {
return this.apiClient.request<NylasResponse<ProviderDetectResponse>>({
method: 'POST',
path: `/v3/providers/detect`,
queryParams: params,
Expand Down
14 changes: 7 additions & 7 deletions src/resources/calendars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
Expand All @@ -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;
}
Expand All @@ -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;
}

Expand All @@ -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;
}
Expand Down
Loading
Loading