The SDK has moved away from large, monolithic models. Instead, it uses specific TypeScript interfaces for different operations to ensure type safety and clarity.
For example, instead of a single Calendar model, the SDK provides:
Calendar: For retrieving an existing calendar.CreateCalendarRequest: For creating a new calendar (contains required fields like name).UpdateCalendarRequest: For updating an existing calendar (all fields are optional).
Models are now pure TypeScript interfaces and no longer contain methods like .save(). To perform actions, use the corresponding methods on the resource class (e.g., .create(), .update(), .destroy()).
// Import only required if you need the typing
import { CreateCalendarRequest, UpdateCalendarRequest } from "nylas/lib/types/models/calendars";
const createCalendarRequest: CreateCalendarRequest = {
name: "My Calendar", // Calendar name is required
description: "This is my calendar", // Calendar description is optional
location: "My calendar location", // Calendar location is optional
timezone: "America/New_York", // Calendar timezone is optional,
}
const updateCalendarRequest: UpdateCalendarRequest = {
name: "My Updated Calendar", // All fields are optional since we are updating
hexColor: "#000000", // Other fields not present during creation are now available
}