nylas 6.2.0 → 6.2.1

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.
@@ -1,5 +1,5 @@
1
1
  import Model from './model';
2
- import RestfulModel from './restful-model';
2
+ declare type AnyModel = new (...args: any[]) => Model;
3
3
  export declare abstract class Attribute {
4
4
  modelKey: string;
5
5
  jsonKey: string;
@@ -18,7 +18,7 @@ declare class AttributeObject extends Attribute {
18
18
  constructor({ modelKey, jsonKey, itemClass, readOnly, }: {
19
19
  modelKey: string;
20
20
  jsonKey?: string;
21
- itemClass?: typeof Model | typeof RestfulModel;
21
+ itemClass?: AnyModel;
22
22
  readOnly?: boolean;
23
23
  });
24
24
  toJSON(val: any, saveRequestBody?: boolean): unknown;
@@ -58,12 +58,12 @@ declare class AttributeCollection extends Attribute {
58
58
  constructor({ modelKey, jsonKey, itemClass, readOnly, }: {
59
59
  modelKey: string;
60
60
  jsonKey?: string;
61
- itemClass: typeof Model | typeof RestfulModel;
61
+ itemClass: AnyModel;
62
62
  readOnly?: boolean;
63
63
  });
64
- toJSON(vals: any, saveRequestBody?: boolean): unknown[];
65
- fromJSON(json: unknown[], _parent: any): typeof Model[] | typeof RestfulModel[] | unknown[];
66
- saveRequestBody(val: any): unknown;
64
+ toJSON(vals: any, saveRequestBody?: boolean): AnyModel[];
65
+ fromJSON(json: unknown[], _parent: any): AnyModel[];
66
+ saveRequestBody(val: any): AnyModel[] | undefined;
67
67
  }
68
68
  declare class AttributeEnum extends Attribute {
69
69
  itemClass: any;
@@ -121,7 +121,7 @@ declare const Attributes: {
121
121
  Collection(__0: {
122
122
  modelKey: string;
123
123
  jsonKey?: string | undefined;
124
- itemClass: typeof Model | typeof RestfulModel;
124
+ itemClass: AnyModel;
125
125
  readOnly?: boolean | undefined;
126
126
  }): AttributeCollection;
127
127
  Boolean(__0: {
@@ -132,7 +132,7 @@ declare const Attributes: {
132
132
  Object(__0: {
133
133
  modelKey: string;
134
134
  jsonKey?: string | undefined;
135
- itemClass?: typeof Model | typeof RestfulModel | undefined;
135
+ itemClass?: AnyModel | undefined;
136
136
  readOnly?: boolean | undefined;
137
137
  }): AttributeObject;
138
138
  Enum(__0: {
@@ -19,15 +19,11 @@ var __spreadArrays = (this && this.__spreadArrays) || function () {
19
19
  r[k] = a[j];
20
20
  return r;
21
21
  };
22
- var __importDefault = (this && this.__importDefault) || function (mod) {
23
- return (mod && mod.__esModule) ? mod : { "default": mod };
24
- };
25
22
  Object.defineProperty(exports, "__esModule", { value: true });
26
- var restful_model_1 = __importDefault(require("./restful-model"));
27
- // The Attribute class represents a single model attribute, like 'namespace_id'
28
- // Subclasses of Attribute like AttributeDateTime know how to covert between
29
- // the JSON representation of that type and the javascript representation.
30
- // The Attribute class also exposes convenience methods for generating Matchers.
23
+ function isRestfulModel(cls) {
24
+ // A 'RestfulModel' has 'endpointName' and 'collectionName' unlike 'Model'
25
+ return cls.endpointName !== undefined && cls.collectionName !== undefined;
26
+ }
31
27
  var Attribute = /** @class */ (function () {
32
28
  function Attribute(_a) {
33
29
  var modelKey = _a.modelKey, jsonKey = _a.jsonKey, readOnly = _a.readOnly;
@@ -68,8 +64,8 @@ var AttributeObject = /** @class */ (function (_super) {
68
64
  if (!val || !this.itemClass) {
69
65
  return val;
70
66
  }
71
- if (this.itemClass.prototype instanceof restful_model_1.default) {
72
- return new this.itemClass(_parent.connection).fromJSON(val);
67
+ if (isRestfulModel(this.itemClass)) {
68
+ return new this.itemClass(_parent.connection, val).fromJSON(val);
73
69
  }
74
70
  return new this.itemClass(val).fromJSON(val);
75
71
  };
@@ -239,8 +235,8 @@ var AttributeCollection = /** @class */ (function (_super) {
239
235
  for (var _i = 0, json_1 = json; _i < json_1.length; _i++) {
240
236
  var objJSON = json_1[_i];
241
237
  var obj = void 0;
242
- if (this.itemClass.prototype instanceof restful_model_1.default) {
243
- obj = new this.itemClass(_parent.connection).fromJSON(objJSON);
238
+ if (isRestfulModel(this.itemClass)) {
239
+ obj = new this.itemClass(_parent.connection, objJSON).fromJSON(objJSON);
244
240
  }
245
241
  else {
246
242
  obj = new this.itemClass(objJSON).fromJSON(objJSON);
@@ -0,0 +1,21 @@
1
+ import OutboxMessage, { OutboxMessageProperties } from './outbox-message';
2
+ import Model from './model';
3
+ import { Attribute } from './attributes';
4
+ import NylasConnection from '../nylas-connection';
5
+ export declare type OutboxJobStatusProperties = {
6
+ jobStatusId: string;
7
+ accountId: string;
8
+ status: string;
9
+ originalData?: OutboxMessageProperties;
10
+ };
11
+ export default class OutboxJobStatus extends Model implements OutboxJobStatusProperties {
12
+ jobStatusId: string;
13
+ status: string;
14
+ accountId: string;
15
+ originalData?: OutboxMessage;
16
+ private _connection?;
17
+ static attributes: Record<string, Attribute>;
18
+ constructor(props?: OutboxJobStatusProperties);
19
+ get connection(): NylasConnection | undefined;
20
+ fromJSON(json: Record<string, unknown>, connection?: NylasConnection): this;
21
+ }
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ extendStatics(d, b);
11
+ function __() { this.constructor = d; }
12
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
+ };
14
+ })();
15
+ var __importDefault = (this && this.__importDefault) || function (mod) {
16
+ return (mod && mod.__esModule) ? mod : { "default": mod };
17
+ };
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ var outbox_message_1 = __importDefault(require("./outbox-message"));
20
+ var model_1 = __importDefault(require("./model"));
21
+ var attributes_1 = __importDefault(require("./attributes"));
22
+ var OutboxJobStatus = /** @class */ (function (_super) {
23
+ __extends(OutboxJobStatus, _super);
24
+ function OutboxJobStatus(props) {
25
+ var _this = _super.call(this) || this;
26
+ _this.jobStatusId = '';
27
+ _this.status = '';
28
+ _this.accountId = '';
29
+ _this.initAttributes(props);
30
+ return _this;
31
+ }
32
+ Object.defineProperty(OutboxJobStatus.prototype, "connection", {
33
+ get: function () {
34
+ return this._connection;
35
+ },
36
+ enumerable: true,
37
+ configurable: true
38
+ });
39
+ OutboxJobStatus.prototype.fromJSON = function (json, connection) {
40
+ // Allow a connection object to be passed in to instantiate a Calendar sub object
41
+ if (connection) {
42
+ this._connection = connection;
43
+ }
44
+ return _super.prototype.fromJSON.call(this, json);
45
+ };
46
+ OutboxJobStatus.attributes = {
47
+ jobStatusId: attributes_1.default.String({
48
+ modelKey: 'jobStatusId',
49
+ jsonKey: 'job_status_id',
50
+ readOnly: true,
51
+ }),
52
+ status: attributes_1.default.String({
53
+ modelKey: 'status',
54
+ readOnly: true,
55
+ }),
56
+ accountId: attributes_1.default.String({
57
+ modelKey: 'accountId',
58
+ jsonKey: 'account_id',
59
+ readOnly: true,
60
+ }),
61
+ originalData: attributes_1.default.Object({
62
+ modelKey: 'originalData',
63
+ jsonKey: 'original_data',
64
+ itemClass: outbox_message_1.default,
65
+ readOnly: true,
66
+ }),
67
+ };
68
+ return OutboxJobStatus;
69
+ }(model_1.default));
70
+ exports.default = OutboxJobStatus;
@@ -0,0 +1,16 @@
1
+ import Draft, { DraftProperties } from './draft';
2
+ import { Attribute } from './attributes';
3
+ import NylasConnection from '../nylas-connection';
4
+ export declare type OutboxMessageProperties = DraftProperties & {
5
+ sendAt: Date;
6
+ retryLimitDatetime?: Date;
7
+ originalSendAt?: Date;
8
+ };
9
+ export default class OutboxMessage extends Draft implements OutboxMessageProperties {
10
+ sendAt: Date;
11
+ retryLimitDatetime?: Date;
12
+ originalSendAt?: Date;
13
+ static collectionName: string;
14
+ static attributes: Record<string, Attribute>;
15
+ constructor(connection: NylasConnection, props?: OutboxMessageProperties);
16
+ }
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ extendStatics(d, b);
11
+ function __() { this.constructor = d; }
12
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
+ };
14
+ })();
15
+ var __assign = (this && this.__assign) || function () {
16
+ __assign = Object.assign || function(t) {
17
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
18
+ s = arguments[i];
19
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
20
+ t[p] = s[p];
21
+ }
22
+ return t;
23
+ };
24
+ return __assign.apply(this, arguments);
25
+ };
26
+ var __importDefault = (this && this.__importDefault) || function (mod) {
27
+ return (mod && mod.__esModule) ? mod : { "default": mod };
28
+ };
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ var draft_1 = __importDefault(require("./draft"));
31
+ var attributes_1 = __importDefault(require("./attributes"));
32
+ var OutboxMessage = /** @class */ (function (_super) {
33
+ __extends(OutboxMessage, _super);
34
+ function OutboxMessage(connection, props) {
35
+ var _this = _super.call(this, connection, props) || this;
36
+ _this.sendAt = new Date();
37
+ _this.initAttributes(props);
38
+ return _this;
39
+ }
40
+ OutboxMessage.collectionName = '/v2/outbox';
41
+ OutboxMessage.attributes = __assign(__assign({}, draft_1.default.attributes), { sendAt: attributes_1.default.DateTime({
42
+ modelKey: 'sendAt',
43
+ jsonKey: 'send_at',
44
+ }), retryLimitDatetime: attributes_1.default.DateTime({
45
+ modelKey: 'retryLimitDatetime',
46
+ jsonKey: 'retry_limit_datetime',
47
+ }), originalSendAt: attributes_1.default.DateTime({
48
+ modelKey: 'originalSendAt',
49
+ jsonKey: 'original_send_at',
50
+ readOnly: true,
51
+ }) });
52
+ return OutboxMessage;
53
+ }(draft_1.default));
54
+ exports.default = OutboxMessage;
@@ -0,0 +1,35 @@
1
+ import NylasConnection from '../nylas-connection';
2
+ import Draft, { SendCallback } from './draft';
3
+ import OutboxJobStatus from './outbox-job-status';
4
+ import Model from './model';
5
+ import { Attribute } from './attributes';
6
+ declare type SendParams = {
7
+ sendAt: Date | number;
8
+ retryLimitDatetime?: Date | number;
9
+ tracking?: Record<string, any>;
10
+ callback?: SendCallback;
11
+ };
12
+ declare type UpdateParams = {
13
+ updatedMessage?: Draft;
14
+ sendAt?: Date | number;
15
+ retryLimitDatetime?: Date | number;
16
+ };
17
+ export declare class SendGridVerifiedStatus extends Model {
18
+ domainVerified?: boolean;
19
+ senderVerified?: boolean;
20
+ static attributes: Record<string, Attribute>;
21
+ }
22
+ export default class Outbox {
23
+ connection: NylasConnection;
24
+ private path;
25
+ constructor(connection: NylasConnection);
26
+ send(draft: Draft, options: SendParams): Promise<OutboxJobStatus>;
27
+ update(jobStatusId: string, options: UpdateParams): Promise<OutboxJobStatus>;
28
+ delete(jobStatusId: string): Promise<void>;
29
+ sendGridVerificationStatus(): Promise<SendGridVerifiedStatus>;
30
+ deleteSendGridSubUser(email: string): Promise<void>;
31
+ private request;
32
+ private static validateAndFormatDateTime;
33
+ private static dateToEpoch;
34
+ }
35
+ export {};
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ extendStatics(d, b);
11
+ function __() { this.constructor = d; }
12
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
+ };
14
+ })();
15
+ var __importDefault = (this && this.__importDefault) || function (mod) {
16
+ return (mod && mod.__esModule) ? mod : { "default": mod };
17
+ };
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ var nylas_connection_1 = require("../nylas-connection");
20
+ var outbox_job_status_1 = __importDefault(require("./outbox-job-status"));
21
+ var model_1 = __importDefault(require("./model"));
22
+ var attributes_1 = __importDefault(require("./attributes"));
23
+ var SendGridVerifiedStatus = /** @class */ (function (_super) {
24
+ __extends(SendGridVerifiedStatus, _super);
25
+ function SendGridVerifiedStatus() {
26
+ return _super !== null && _super.apply(this, arguments) || this;
27
+ }
28
+ SendGridVerifiedStatus.attributes = {
29
+ domainVerified: attributes_1.default.Boolean({
30
+ modelKey: 'domainVerified',
31
+ jsonKey: 'domain_verified',
32
+ }),
33
+ senderVerified: attributes_1.default.Boolean({
34
+ modelKey: 'senderVerified',
35
+ jsonKey: 'sender_verified',
36
+ }),
37
+ };
38
+ return SendGridVerifiedStatus;
39
+ }(model_1.default));
40
+ exports.SendGridVerifiedStatus = SendGridVerifiedStatus;
41
+ var Outbox = /** @class */ (function () {
42
+ function Outbox(connection) {
43
+ this.path = '/v2/outbox';
44
+ this.connection = connection;
45
+ }
46
+ Outbox.prototype.send = function (draft, options) {
47
+ var _this = this;
48
+ var body = draft.saveRequestBody();
49
+ if (options.tracking) {
50
+ body['tracking'] = options.tracking;
51
+ }
52
+ var _a = Outbox.validateAndFormatDateTime(options.sendAt, options.retryLimitDatetime), sendAt = _a[0], retryLimitDatetime = _a[1];
53
+ body['send_at'] = sendAt;
54
+ body['retry_limit_datetime'] = retryLimitDatetime;
55
+ return this.request({
56
+ method: 'POST',
57
+ path: '',
58
+ body: body,
59
+ })
60
+ .then(function (json) {
61
+ var message = new outbox_job_status_1.default().fromJSON(json, _this.connection);
62
+ if (options.callback) {
63
+ options.callback(null, message);
64
+ }
65
+ return Promise.resolve(message);
66
+ })
67
+ .catch(function (err) {
68
+ if (options.callback) {
69
+ options.callback(err);
70
+ }
71
+ return Promise.reject(err);
72
+ });
73
+ };
74
+ Outbox.prototype.update = function (jobStatusId, options) {
75
+ var _this = this;
76
+ var body = {};
77
+ if (options.updatedMessage) {
78
+ body = options.updatedMessage.saveRequestBody();
79
+ }
80
+ var _a = Outbox.validateAndFormatDateTime(options.sendAt, options.retryLimitDatetime), sendAt = _a[0], retryLimitDatetime = _a[1];
81
+ body['send_at'] = sendAt;
82
+ body['retry_limit_datetime'] = retryLimitDatetime;
83
+ return this.request({
84
+ method: 'PATCH',
85
+ path: "/" + jobStatusId,
86
+ body: body,
87
+ }).then(function (json) {
88
+ var message = new outbox_job_status_1.default().fromJSON(json, _this.connection);
89
+ return Promise.resolve(message);
90
+ });
91
+ };
92
+ Outbox.prototype.delete = function (jobStatusId) {
93
+ return this.request({
94
+ method: 'DELETE',
95
+ path: "/" + jobStatusId,
96
+ });
97
+ };
98
+ Outbox.prototype.sendGridVerificationStatus = function () {
99
+ return this.request({
100
+ method: 'GET',
101
+ path: "/onboard/verified_status",
102
+ }).then(function (json) {
103
+ if (json.results) {
104
+ json = json.results;
105
+ }
106
+ var verifiedStatus = new SendGridVerifiedStatus().fromJSON(json);
107
+ return Promise.resolve(verifiedStatus);
108
+ });
109
+ };
110
+ Outbox.prototype.deleteSendGridSubUser = function (email) {
111
+ return this.request({
112
+ method: 'DELETE',
113
+ path: "/onboard/subuser",
114
+ body: { email: email },
115
+ });
116
+ };
117
+ Outbox.prototype.request = function (options) {
118
+ var header;
119
+ if (options.body) {
120
+ header = {
121
+ 'Content-Type': 'application/json',
122
+ };
123
+ }
124
+ return this.connection.request({
125
+ method: options.method,
126
+ path: "" + this.path + options.path,
127
+ body: options.body,
128
+ headers: header,
129
+ authMethod: nylas_connection_1.AuthMethod.BEARER,
130
+ });
131
+ };
132
+ Outbox.validateAndFormatDateTime = function (sendAt, retryLimitDatetime) {
133
+ var sendAtEpoch = sendAt instanceof Date ? Outbox.dateToEpoch(sendAt) : sendAt;
134
+ var retryLimitDatetimeEpoch = retryLimitDatetime instanceof Date
135
+ ? Outbox.dateToEpoch(retryLimitDatetime)
136
+ : retryLimitDatetime;
137
+ if (sendAtEpoch && sendAtEpoch !== 0) {
138
+ if (sendAtEpoch < Outbox.dateToEpoch(new Date())) {
139
+ throw new Error('Cannot set message to be sent at a time before the current time.');
140
+ }
141
+ }
142
+ if (retryLimitDatetimeEpoch && retryLimitDatetimeEpoch !== 0) {
143
+ var validSendAt = sendAtEpoch;
144
+ if (!validSendAt || validSendAt === 0) {
145
+ validSendAt = Outbox.dateToEpoch(new Date());
146
+ }
147
+ if (retryLimitDatetimeEpoch < validSendAt) {
148
+ throw new Error('Cannot set message to stop retrying before time to send at.');
149
+ }
150
+ }
151
+ return [sendAtEpoch, retryLimitDatetimeEpoch];
152
+ };
153
+ Outbox.dateToEpoch = function (date) {
154
+ return Math.floor(date.getTime() / 1000.0);
155
+ };
156
+ return Outbox;
157
+ }());
158
+ exports.default = Outbox;
@@ -34,6 +34,7 @@ export declare type SchedulerAppearanceProperties = {
34
34
  showAutoschedule?: boolean;
35
35
  showNylasBranding?: boolean;
36
36
  showTimezoneOptions?: boolean;
37
+ showWeekView?: boolean;
37
38
  submitText?: string;
38
39
  thankYouRedirect?: string;
39
40
  thankYouText?: string;
@@ -47,6 +48,7 @@ export declare class SchedulerAppearance extends Model implements SchedulerAppea
47
48
  showAutoschedule?: boolean;
48
49
  showNylasBranding?: boolean;
49
50
  showTimezoneOptions?: boolean;
51
+ showWeekView?: boolean;
50
52
  submitText?: string;
51
53
  thankYouRedirect?: string;
52
54
  thankYouText?: string;
@@ -78,13 +80,13 @@ export declare class SchedulerBookingAdditionalFields extends Model implements S
78
80
  }
79
81
  export declare type SchedulerBookingOpeningHoursProperties = {
80
82
  accountId?: string;
81
- days?: string;
83
+ days?: string[];
82
84
  end?: string;
83
85
  start?: string;
84
86
  };
85
87
  export declare class SchedulerBookingOpeningHours extends Model implements SchedulerBookingOpeningHoursProperties {
86
88
  accountId?: string;
87
- days?: string;
89
+ days?: string[];
88
90
  end?: string;
89
91
  start?: string;
90
92
  static attributes: Record<string, Attribute>;
@@ -92,6 +94,7 @@ export declare class SchedulerBookingOpeningHours extends Model implements Sched
92
94
  }
93
95
  export declare type SchedulerBookingProperties = {
94
96
  additionalFields?: SchedulerBookingAdditionalFieldsProperties[];
97
+ additionalGuestsHidden?: boolean;
95
98
  availableDaysInFuture?: number;
96
99
  calendarInviteToGuests?: boolean;
97
100
  cancellationPolicy?: string;
@@ -107,6 +110,7 @@ export declare type SchedulerBookingProperties = {
107
110
  };
108
111
  export declare class SchedulerBooking extends Model implements SchedulerBookingProperties {
109
112
  additionalFields?: SchedulerBookingAdditionalFields[];
113
+ additionalGuestsHidden?: boolean;
110
114
  availableDaysInFuture?: number;
111
115
  calendarInviteToGuests?: boolean;
112
116
  cancellationPolicy?: string;
@@ -179,6 +183,7 @@ export declare class SchedulerConfig extends Model implements SchedulerConfigPro
179
183
  date?: number;
180
184
  uses?: number;
181
185
  };
186
+ disableEmails?: boolean;
182
187
  locale?: string;
183
188
  localeForGuests?: string;
184
189
  reminders?: SchedulerRemindersProperties[];
@@ -108,6 +108,10 @@ var SchedulerAppearance = /** @class */ (function (_super) {
108
108
  modelKey: 'showTimezoneOptions',
109
109
  jsonKey: 'show_timezone_options',
110
110
  }),
111
+ showWeekView: attributes_1.default.Boolean({
112
+ modelKey: 'showWeekView',
113
+ jsonKey: 'show_week_view',
114
+ }),
111
115
  submitText: attributes_1.default.String({
112
116
  modelKey: 'submitText',
113
117
  jsonKey: 'submit_text',
@@ -178,7 +182,7 @@ var SchedulerBookingOpeningHours = /** @class */ (function (_super) {
178
182
  modelKey: 'accountId',
179
183
  jsonKey: 'account_id',
180
184
  }),
181
- days: attributes_1.default.String({
185
+ days: attributes_1.default.StringList({
182
186
  modelKey: 'days',
183
187
  }),
184
188
  end: attributes_1.default.String({
@@ -204,6 +208,10 @@ var SchedulerBooking = /** @class */ (function (_super) {
204
208
  jsonKey: 'additional_fields',
205
209
  itemClass: SchedulerBookingAdditionalFields,
206
210
  }),
211
+ additionalGuestsHidden: attributes_1.default.Boolean({
212
+ modelKey: 'additionalGuestsHidden',
213
+ jsonKey: 'additional_guests_hidden',
214
+ }),
207
215
  availableDaysInFuture: attributes_1.default.Number({
208
216
  modelKey: 'availableDaysInFuture',
209
217
  jsonKey: 'available_days_in_future',
@@ -316,6 +324,10 @@ var SchedulerConfig = /** @class */ (function (_super) {
316
324
  modelKey: 'expireAfter',
317
325
  jsonKey: 'expire_after',
318
326
  }),
327
+ disableEmails: attributes_1.default.Boolean({
328
+ modelKey: 'disableEmails',
329
+ jsonKey: 'disable_emails',
330
+ }),
319
331
  locale: attributes_1.default.String({
320
332
  modelKey: 'locale',
321
333
  }),
@@ -19,6 +19,11 @@ import ComponentRestfulModelCollection from './models/component-restful-model-co
19
19
  import SchedulerRestfulModelCollection from './models/scheduler-restful-model-collection';
20
20
  import MessageRestfulModelCollection from './models/message-restful-model-collection';
21
21
  import DeltaCollection from './models/delta-collection';
22
+ import Outbox from './models/outbox';
23
+ export declare enum AuthMethod {
24
+ BASIC = 0,
25
+ BEARER = 1
26
+ }
22
27
  export declare type RequestOptions = {
23
28
  path: string;
24
29
  method?: string;
@@ -30,6 +35,7 @@ export declare type RequestOptions = {
30
35
  body?: any;
31
36
  baseUrl?: string;
32
37
  url?: URL;
38
+ authMethod?: AuthMethod;
33
39
  };
34
40
  export declare type FormDataType = {
35
41
  value: unknown;
@@ -53,6 +59,7 @@ export default class NylasConnection {
53
59
  account: RestfulModelInstance<Account>;
54
60
  component: ComponentRestfulModelCollection;
55
61
  scheduler: SchedulerRestfulModelCollection;
62
+ outbox: Outbox;
56
63
  neural: Neural;
57
64
  constructor(accessToken: string | null | undefined, { clientId }: {
58
65
  clientId: string | null | undefined;
@@ -44,9 +44,15 @@ var component_restful_model_collection_1 = __importDefault(require("./models/com
44
44
  var scheduler_restful_model_collection_1 = __importDefault(require("./models/scheduler-restful-model-collection"));
45
45
  var message_restful_model_collection_1 = __importDefault(require("./models/message-restful-model-collection"));
46
46
  var delta_collection_1 = __importDefault(require("./models/delta-collection"));
47
+ var outbox_1 = __importDefault(require("./models/outbox"));
47
48
  var PACKAGE_JSON = require('../package.json');
48
49
  var SDK_VERSION = PACKAGE_JSON.version;
49
- var SUPPORTED_API_VERSION = '2.3';
50
+ var SUPPORTED_API_VERSION = '2.5';
51
+ var AuthMethod;
52
+ (function (AuthMethod) {
53
+ AuthMethod[AuthMethod["BASIC"] = 0] = "BASIC";
54
+ AuthMethod[AuthMethod["BEARER"] = 1] = "BEARER";
55
+ })(AuthMethod = exports.AuthMethod || (exports.AuthMethod = {}));
50
56
  var NylasConnection = /** @class */ (function () {
51
57
  function NylasConnection(accessToken, _a) {
52
58
  var clientId = _a.clientId;
@@ -65,6 +71,7 @@ var NylasConnection = /** @class */ (function () {
65
71
  this.account = new restful_model_instance_1.default(account_1.default, this);
66
72
  this.component = new component_restful_model_collection_1.default(this);
67
73
  this.scheduler = new scheduler_restful_model_collection_1.default(this);
74
+ this.outbox = new outbox_1.default(this);
68
75
  this.neural = new neural_1.default(this);
69
76
  this.accessToken = accessToken;
70
77
  this.clientId = clientId;
@@ -107,8 +114,13 @@ var NylasConnection = /** @class */ (function () {
107
114
  ? config.clientSecret
108
115
  : this.accessToken;
109
116
  if (user) {
110
- headers['authorization'] =
111
- 'Basic ' + Buffer.from(user + ":", 'utf8').toString('base64');
117
+ if (options.authMethod === AuthMethod.BEARER) {
118
+ headers['authorization'] = "Bearer " + user;
119
+ }
120
+ else {
121
+ headers['authorization'] =
122
+ 'Basic ' + Buffer.from(user + ":", 'utf8').toString('base64');
123
+ }
112
124
  }
113
125
  if (!headers['User-Agent']) {
114
126
  headers['User-Agent'] = "Nylas Node SDK v" + SDK_VERSION;
@@ -209,6 +221,10 @@ var NylasConnection = /** @class */ (function () {
209
221
  return reject(e);
210
222
  });
211
223
  }
224
+ else if (response.headers.get('content-length') &&
225
+ Number(response.headers.get('content-length')) == 0) {
226
+ return resolve();
227
+ }
212
228
  else if (response.headers.get('Content-Type') === 'message/rfc822') {
213
229
  return resolve(response.text());
214
230
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nylas",
3
- "version": "6.2.0",
3
+ "version": "6.2.1",
4
4
  "description": "A NodeJS wrapper for the Nylas REST API for email, contacts, and calendar.",
5
5
  "main": "lib/nylas.js",
6
6
  "types": "lib/nylas.d.ts",