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

Separate Nylas @types package? #461

Open
tvongaza opened this issue May 1, 2023 · 1 comment
Open

Separate Nylas @types package? #461

tvongaza opened this issue May 1, 2023 · 1 comment

Comments

@tvongaza
Copy link

tvongaza commented May 1, 2023

Is your feature request related to a problem? Please describe.

We're integrating with Nylas and in our typescript front end code want to make use of types for the Nylas data. Turns out all the types are defined in the nylas-nodejs repo, but are inlined in the modes (example: https://github.com/nylas/nylas-nodejs/blob/main/src/models/event.ts#L35). We do not want to include the nodejs package for our front end code when we just need the types.

Describe the solution you'd like

It would be great to have a nylas maintained @types (via https://github.com/DefinitelyTyped/DefinitelyTyped or your own) package which defines all the typescript types. This could be used in your nodejs app, or front end code.

Describe alternatives you've considered

Currently I've just copied and pasted the types into my own types file as needed. It works, but will be prone to getting outdated if Nylas's types ever change.

Additional context

Example file:

export type NylasEvent = EventProperties & RestfulModelJSON & EventPropertiesAdditions;

interface EventPropertiesAdditions {
  updatedAt: number;
}

interface RestfulModelJSON {
  id: string;
  object: string;
  accountId: string;
  // [key: string]: any;
}

type EventProperties = {
  calendarId: string;
  when: WhenProperties;
  iCalUID?: string;
  messageId?: string;
  eventCollectionId?: string | number;
  title?: string;
  description?: string;
  owner?: string;
  participants?: EventParticipantProperties[];
  readOnly?: boolean;
  location?: string;
  busy?: boolean;
  status?: string;
  recurrence?: {
    rrule: string[];
    timezone: string;
  };
  masterEventId?: string;
  originalStartTime?: Date;
  capacity?: number;
  conferencing?: EventConferencingProperties;
  notifications?: EventNotificationProperties[];
  roundRobinOrder?: string[];
  metadata?: object;
  jobStatusId?: string;
  organizerEmail?: string;
  organizerName?: string;
  hideParticipants?: boolean;
  visibility?: string;
  customerEventId?: string;
  reminderMinutes?: string;
  reminderMethod?: EventReminderMethod;
  reminders?: EventReminderProperties;
};

export type WhenProperties = {
  startTime?: number;
  endTime?: number;
  startTimezone?: string;
  endTimezone?: string;
  time?: number;
  timezone?: string;
  startDate?: string;
  endDate?: string;
  date?: string;
  object?: string;
};

export type EventParticipantProperties = {
  email: string;
  name?: string;
  comment?: string;
  phoneNumber?: string;
  status?: string;
};

export type EventConferencingProperties = {
  provider: string;
  details?: EventConferencingDetailsProperties;
  autocreate?: {
    settings?: object;
  };
};

export type EventConferencingDetailsProperties = {
  meetingCode?: string;
  phone?: string[];
  password?: string;
  pin?: string;
  url?: string;
};

export enum EventNotificationType {
  Email = 'email',
  Sms = 'sms',
  Webhook = 'webhook',
}

export type EventNotificationProperties = {
  type: EventNotificationType;
  minutesBeforeEvent: number;
  url?: string;
  payload?: string;
  subject?: string;
  body?: string;
  message?: string;
};

export enum EventReminderMethod {
  Email = 'email',
  Popup = 'popup',
  Display = 'display',
  Sound = 'sound',
}

export type EventReminderProperties = {
  reminderMinutes?: string;
  reminderMethod?: EventReminderMethod;
};
@joshuatshaffer
Copy link

TypeScript has type-only imports that are always fully erased so that there is no remnant of them at runtime. You should be able to get the same effect as a @types/ package by using import type ... from 'nylas' and making nylas a devDependency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants