nylas 7.2.1 → 7.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,10 +9,11 @@ const version_js_1 = require("./version.js");
9
9
  * @ignore Not for public use
10
10
  */
11
11
  class APIClient {
12
- constructor({ apiKey, apiUri, timeout }) {
12
+ constructor({ apiKey, apiUri, timeout, headers }) {
13
13
  this.apiKey = apiKey;
14
14
  this.serverUrl = apiUri;
15
15
  this.timeout = timeout * 1000; // fetch timeout uses milliseconds
16
+ this.headers = headers;
16
17
  }
17
18
  setRequestUrl({ overrides, path, queryParams, }) {
18
19
  const url = new URL(`${overrides?.apiUri || this.serverUrl}${path}`);
@@ -39,11 +40,16 @@ class APIClient {
39
40
  return url;
40
41
  }
41
42
  setRequestHeaders({ headers, overrides, }) {
43
+ const mergedHeaders = {
44
+ ...headers,
45
+ ...this.headers,
46
+ ...overrides?.headers,
47
+ };
42
48
  return {
43
49
  Accept: 'application/json',
44
50
  'User-Agent': `Nylas Node SDK v${version_js_1.SDK_VERSION}`,
45
51
  Authorization: `Bearer ${overrides?.apiKey || this.apiKey}`,
46
- ...headers,
52
+ ...mergedHeaders,
47
53
  };
48
54
  }
49
55
  async sendRequest(options) {
package/lib/cjs/nylas.js CHANGED
@@ -45,6 +45,7 @@ class Nylas {
45
45
  apiKey: config.apiKey,
46
46
  apiUri: config.apiUri || config_js_1.DEFAULT_SERVER_URL,
47
47
  timeout: config.timeout || 90,
48
+ headers: config.headers || {},
48
49
  });
49
50
  this.applications = new applications_js_1.Applications(this.apiClient);
50
51
  this.auth = new auth_js_1.Auth(this.apiClient);
@@ -149,9 +149,9 @@ class Auth extends resource_js_1.Resource {
149
149
  }
150
150
  if (config.loginHint) {
151
151
  url.searchParams.set('login_hint', config.loginHint);
152
- if (config.includeGrantScopes) {
153
- url.searchParams.set('include_grant_scopes', config.includeGrantScopes.toString());
154
- }
152
+ }
153
+ if (config.includeGrantScopes !== undefined) {
154
+ url.searchParams.set('include_grant_scopes', config.includeGrantScopes.toString());
155
155
  }
156
156
  if (config.scope) {
157
157
  url.searchParams.set('scope', config.scope.join(' '));
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
4
  // This file is generated by scripts/exportVersion.js
5
- exports.SDK_VERSION = '7.2.1';
5
+ exports.SDK_VERSION = '7.3.0';
@@ -7,10 +7,11 @@ import { SDK_VERSION } from './version.js';
7
7
  * @ignore Not for public use
8
8
  */
9
9
  export default class APIClient {
10
- constructor({ apiKey, apiUri, timeout }) {
10
+ constructor({ apiKey, apiUri, timeout, headers }) {
11
11
  this.apiKey = apiKey;
12
12
  this.serverUrl = apiUri;
13
13
  this.timeout = timeout * 1000; // fetch timeout uses milliseconds
14
+ this.headers = headers;
14
15
  }
15
16
  setRequestUrl({ overrides, path, queryParams, }) {
16
17
  const url = new URL(`${overrides?.apiUri || this.serverUrl}${path}`);
@@ -37,11 +38,16 @@ export default class APIClient {
37
38
  return url;
38
39
  }
39
40
  setRequestHeaders({ headers, overrides, }) {
41
+ const mergedHeaders = {
42
+ ...headers,
43
+ ...this.headers,
44
+ ...overrides?.headers,
45
+ };
40
46
  return {
41
47
  Accept: 'application/json',
42
48
  'User-Agent': `Nylas Node SDK v${SDK_VERSION}`,
43
49
  Authorization: `Bearer ${overrides?.apiKey || this.apiKey}`,
44
- ...headers,
50
+ ...mergedHeaders,
45
51
  };
46
52
  }
47
53
  async sendRequest(options) {
package/lib/esm/nylas.js CHANGED
@@ -29,6 +29,7 @@ export default class Nylas {
29
29
  apiKey: config.apiKey,
30
30
  apiUri: config.apiUri || DEFAULT_SERVER_URL,
31
31
  timeout: config.timeout || 90,
32
+ headers: config.headers || {},
32
33
  });
33
34
  this.applications = new Applications(this.apiClient);
34
35
  this.auth = new Auth(this.apiClient);
@@ -146,9 +146,9 @@ export class Auth extends Resource {
146
146
  }
147
147
  if (config.loginHint) {
148
148
  url.searchParams.set('login_hint', config.loginHint);
149
- if (config.includeGrantScopes) {
150
- url.searchParams.set('include_grant_scopes', config.includeGrantScopes.toString());
151
- }
149
+ }
150
+ if (config.includeGrantScopes !== undefined) {
151
+ url.searchParams.set('include_grant_scopes', config.includeGrantScopes.toString());
152
152
  }
153
153
  if (config.scope) {
154
154
  url.searchParams.set('scope', config.scope.join(' '));
@@ -1,2 +1,2 @@
1
1
  // This file is generated by scripts/exportVersion.js
2
- export const SDK_VERSION = '7.2.1';
2
+ export const SDK_VERSION = '7.3.0';
@@ -57,7 +57,11 @@ export default class APIClient {
57
57
  * The timeout for requests to the Nylas API, in seconds
58
58
  */
59
59
  timeout: number;
60
- constructor({ apiKey, apiUri, timeout }: Required<NylasConfig>);
60
+ /**
61
+ * Additional headers to send with outgoing requests
62
+ */
63
+ headers: Record<string, string>;
64
+ constructor({ apiKey, apiUri, timeout, headers }: Required<NylasConfig>);
61
65
  private setRequestUrl;
62
66
  private setQueryStrings;
63
67
  private setRequestHeaders;
@@ -3,11 +3,13 @@
3
3
  * @property apiKey The Nylas API key to use for authentication
4
4
  * @property apiUri The URL to use for communicating with the Nylas API
5
5
  * @property timeout The timeout for requests to the Nylas API, in seconds
6
+ * @property headers Additional headers to send with outgoing requests
6
7
  */
7
8
  export type NylasConfig = {
8
9
  apiKey: string;
9
10
  apiUri?: string;
10
11
  timeout?: number;
12
+ headers?: Record<string, string>;
11
13
  };
12
14
  /**
13
15
  * The options that can override the default Nylas API client configuration.
@@ -2,6 +2,16 @@ import { BaseMessage } from './messages.js';
2
2
  import { ListQueryParams } from './listQueryParams.js';
3
3
  import { EmailName } from './events.js';
4
4
  import { CreateAttachmentRequest } from './attachments.js';
5
+ export interface CustomHeader {
6
+ /**
7
+ * The name of the custom header.
8
+ */
9
+ name: string;
10
+ /**
11
+ * The value of the custom header.
12
+ */
13
+ value: string;
14
+ }
5
15
  /**
6
16
  * Interface representing a request to create a draft.
7
17
  */
@@ -55,6 +65,10 @@ export interface CreateDraftRequest {
55
65
  * Options for tracking opens, links, and thread replies.
56
66
  */
57
67
  trackingOptions?: TrackingOptions;
68
+ /**
69
+ * An array of custom headers to add to the message.
70
+ */
71
+ customHeaders?: CustomHeader[];
58
72
  }
59
73
  /**
60
74
  * Interface representing a request to send a message.
@@ -1,5 +1,7 @@
1
1
  import { ListQueryParams } from './listQueryParams.js';
2
2
  import { Subset } from '../utils.js';
3
+ import { NylasBaseResponse } from './response.js';
4
+ import { NylasApiErrorResponseData } from './error.js';
3
5
  /**
4
6
  * Interface representing a Nylas Event object.
5
7
  */
@@ -192,6 +194,13 @@ export type UpdateEventRequest = Subset<CreateEventRequest>;
192
194
  export type SendRsvpRequest = {
193
195
  status: RsvpStatus;
194
196
  };
197
+ /**
198
+ * Interface representing the response from sending RSVP to an event.
199
+ * @property sendIcsError If the send-rsvp request succeeded but the ICS email could not be sent, this will contain the error.
200
+ */
201
+ export interface SendRsvpResponse extends NylasBaseResponse {
202
+ sendIcsError?: NylasApiErrorResponseData;
203
+ }
195
204
  /**
196
205
  * Interface representing the query parameters for listing events.
197
206
  */
@@ -329,7 +338,7 @@ type When = Time | Timespan | Date | Datespan;
329
338
  /**
330
339
  * Type representing the different objects representing time and duration when creating events.
331
340
  */
332
- type CreateWhen = Omit<Time, 'type'> | Omit<Timespan, 'type'> | Omit<Date, 'type'> | Omit<Datespan, 'type'>;
341
+ type CreateWhen = Omit<Time, 'object'> | Omit<Timespan, 'object'> | Omit<Date, 'object'> | Omit<Datespan, 'object'>;
333
342
  /**
334
343
  * Enum representing the different types of when objects.
335
344
  */
@@ -409,7 +418,7 @@ export interface Time {
409
418
  /**
410
419
  * The type of 'when' object.
411
420
  */
412
- type: WhenType.Time;
421
+ object: WhenType.Time;
413
422
  }
414
423
  /**
415
424
  * Class representation of a time span with start and end times.
@@ -439,7 +448,7 @@ export interface Timespan {
439
448
  /**
440
449
  * The type of 'when' object.
441
450
  */
442
- type: WhenType.Timespan;
451
+ object: WhenType.Timespan;
443
452
  }
444
453
  /**
445
454
  * Class representation of an entire day spans without specific times.
@@ -454,7 +463,7 @@ export interface Date {
454
463
  /**
455
464
  * The type of 'when' object.
456
465
  */
457
- type: WhenType.Date;
466
+ object: WhenType.Date;
458
467
  }
459
468
  /**
460
469
  * Class representation of a specific dates without clock-based start or end times.
@@ -474,7 +483,7 @@ export interface Datespan {
474
483
  /**
475
484
  * The type of 'when' object.
476
485
  */
477
- type: WhenType.Datespan;
486
+ object: WhenType.Datespan;
478
487
  }
479
488
  /**
480
489
  * Interface representing an Event participant.
@@ -523,7 +532,7 @@ export interface ReminderOverride {
523
532
  * The number of minutes before the event start time when a user wants a reminder for this event.
524
533
  * Reminder minutes are in the following format: "[20]".
525
534
  */
526
- reminderMinutes: string;
535
+ reminderMinutes: number;
527
536
  /**
528
537
  * Method to remind the user about the event. (Google only).
529
538
  */
@@ -1,5 +1,5 @@
1
1
  import { Overrides } from '../config.js';
2
- import { CreateEventQueryParams, CreateEventRequest, DestroyEventQueryParams, Event, FindEventQueryParams, ListEventQueryParams, SendRsvpQueryParams, SendRsvpRequest, UpdateEventQueryParams, UpdateEventRequest } from '../models/events.js';
2
+ import { CreateEventQueryParams, CreateEventRequest, DestroyEventQueryParams, Event, FindEventQueryParams, ListEventQueryParams, SendRsvpQueryParams, SendRsvpRequest, SendRsvpResponse, UpdateEventQueryParams, UpdateEventRequest } from '../models/events.js';
3
3
  import { NylasBaseResponse, NylasResponse, NylasListResponse } from '../models/response.js';
4
4
  import { AsyncListResponse, Resource } from './resource.js';
5
5
  /**
@@ -101,6 +101,6 @@ export declare class Events extends Resource {
101
101
  * You cannot directly update events as an invitee, since you are not the owner/organizer.
102
102
  * @return The send-rsvp response
103
103
  */
104
- sendRsvp({ identifier, eventId, requestBody, queryParams, overrides, }: SendRsvpParams & Overrides): Promise<NylasBaseResponse>;
104
+ sendRsvp({ identifier, eventId, requestBody, queryParams, overrides, }: SendRsvpParams & Overrides): Promise<SendRsvpResponse>;
105
105
  }
106
106
  export {};
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "7.2.1";
1
+ export declare const SDK_VERSION = "7.3.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nylas",
3
- "version": "7.2.1",
3
+ "version": "7.3.0",
4
4
  "description": "A NodeJS wrapper for the Nylas REST API for email, contacts, and calendar.",
5
5
  "main": "lib/cjs/nylas.js",
6
6
  "types": "lib/types/nylas.d.ts",