nylas 6.4.0 → 6.5.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.
- package/lib/models/event.d.ts +3 -2
- package/lib/models/event.js +3 -0
- package/lib/models/job-status.d.ts +2 -0
- package/lib/models/job-status.js +3 -0
- package/lib/models/message.d.ts +2 -1
- package/lib/models/message.js +8 -0
- package/lib/models/scheduler.d.ts +3 -0
- package/lib/models/scheduler.js +15 -2
- package/lib/nylas-connection.js +22 -28
- package/package.json +1 -1
package/lib/models/event.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export declare type EventProperties = {
|
|
|
37
37
|
timezone: string;
|
|
38
38
|
};
|
|
39
39
|
masterEventId?: string;
|
|
40
|
-
originalStartTime?:
|
|
40
|
+
originalStartTime?: Date;
|
|
41
41
|
capacity?: number;
|
|
42
42
|
conferencing?: EventConferencingProperties;
|
|
43
43
|
notifications?: EventNotificationProperties[];
|
|
@@ -64,9 +64,10 @@ export default class Event extends RestfulModel {
|
|
|
64
64
|
timezone: string;
|
|
65
65
|
};
|
|
66
66
|
masterEventId?: string;
|
|
67
|
-
originalStartTime?:
|
|
67
|
+
originalStartTime?: Date;
|
|
68
68
|
capacity?: number;
|
|
69
69
|
conferencing?: EventConferencing;
|
|
70
|
+
reminderMinutes?: string;
|
|
70
71
|
notifications?: EventNotification[];
|
|
71
72
|
roundRobinOrder?: string[];
|
|
72
73
|
metadata?: object;
|
package/lib/models/event.js
CHANGED
|
@@ -258,6 +258,9 @@ var Event = /** @class */ (function (_super) {
|
|
|
258
258
|
}), conferencing: attributes_1.default.Object({
|
|
259
259
|
modelKey: 'conferencing',
|
|
260
260
|
itemClass: event_conferencing_1.default,
|
|
261
|
+
}), reminderMinutes: attributes_1.default.String({
|
|
262
|
+
modelKey: 'reminderMinutes',
|
|
263
|
+
jsonKey: 'reminder_minutes',
|
|
261
264
|
}), notifications: attributes_1.default.Collection({
|
|
262
265
|
modelKey: 'notifications',
|
|
263
266
|
itemClass: event_notification_1.default,
|
|
@@ -8,6 +8,7 @@ export declare type JobStatusProperties = {
|
|
|
8
8
|
jobStatusId?: string;
|
|
9
9
|
status?: string;
|
|
10
10
|
originalData?: Message;
|
|
11
|
+
metadata?: object;
|
|
11
12
|
};
|
|
12
13
|
export default class JobStatus extends RestfulModel implements JobStatusProperties {
|
|
13
14
|
action?: string;
|
|
@@ -15,6 +16,7 @@ export default class JobStatus extends RestfulModel implements JobStatusProperti
|
|
|
15
16
|
jobStatusId?: string;
|
|
16
17
|
status?: string;
|
|
17
18
|
originalData?: Message;
|
|
19
|
+
metadata?: object;
|
|
18
20
|
static collectionName: string;
|
|
19
21
|
static attributes: Record<string, Attribute>;
|
|
20
22
|
constructor(connection: NylasConnection, props?: JobStatusProperties);
|
package/lib/models/job-status.js
CHANGED
|
@@ -59,6 +59,9 @@ var JobStatus = /** @class */ (function (_super) {
|
|
|
59
59
|
modelKey: 'originalData',
|
|
60
60
|
jsonKey: 'original_data',
|
|
61
61
|
readOnly: true,
|
|
62
|
+
}), metadata: attributes_1.default.Object({
|
|
63
|
+
modelKey: 'metadata',
|
|
64
|
+
readOnly: true,
|
|
62
65
|
}) });
|
|
63
66
|
return JobStatus;
|
|
64
67
|
}(restful_model_1.default));
|
package/lib/models/message.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import RestfulModel from './restful-model';
|
|
1
|
+
import RestfulModel, { SaveCallback } from './restful-model';
|
|
2
2
|
import { Attribute } from './attributes';
|
|
3
3
|
import File, { FileProperties } from './file';
|
|
4
4
|
import Event, { EventProperties } from './event';
|
|
@@ -53,4 +53,5 @@ export default class Message extends RestfulModel implements MessageProperties {
|
|
|
53
53
|
fileIds(): (string | undefined)[];
|
|
54
54
|
getRaw(): Promise<string>;
|
|
55
55
|
saveRequestBody(): Record<string, unknown>;
|
|
56
|
+
save(params?: {} | SaveCallback, callback?: SaveCallback): Promise<this>;
|
|
56
57
|
}
|
package/lib/models/message.js
CHANGED
|
@@ -106,6 +106,14 @@ var Message = /** @class */ (function (_super) {
|
|
|
106
106
|
json['metadata'] = this.metadata;
|
|
107
107
|
return json;
|
|
108
108
|
};
|
|
109
|
+
Message.prototype.save = function (params, callback) {
|
|
110
|
+
if (params === void 0) { params = {}; }
|
|
111
|
+
// A Message can only be updated
|
|
112
|
+
if (this.constructor.name === 'Message' && !this.id) {
|
|
113
|
+
throw new Error('Cannot create a message. Please create and send a draft instead.');
|
|
114
|
+
}
|
|
115
|
+
return _super.prototype.save.call(this, params, callback);
|
|
116
|
+
};
|
|
109
117
|
Message.collectionName = 'messages';
|
|
110
118
|
Message.attributes = __assign(__assign({}, restful_model_1.default.attributes), { subject: attributes_1.default.String({
|
|
111
119
|
modelKey: 'subject',
|
|
@@ -104,6 +104,7 @@ export declare type SchedulerBookingProperties = {
|
|
|
104
104
|
minBookingNotice?: number;
|
|
105
105
|
minBuffer?: number;
|
|
106
106
|
minCancellationNotice?: number;
|
|
107
|
+
intervalMinutes?: number;
|
|
107
108
|
nameFieldHidden?: boolean;
|
|
108
109
|
openingHours?: SchedulerBookingOpeningHoursProperties[];
|
|
109
110
|
schedulingMethod?: string;
|
|
@@ -120,6 +121,7 @@ export declare class SchedulerBooking extends Model implements SchedulerBookingP
|
|
|
120
121
|
minBookingNotice?: number;
|
|
121
122
|
minBuffer?: number;
|
|
122
123
|
minCancellationNotice?: number;
|
|
124
|
+
intervalMinutes?: number;
|
|
123
125
|
nameFieldHidden?: boolean;
|
|
124
126
|
openingHours?: SchedulerBookingOpeningHours[];
|
|
125
127
|
schedulingMethod?: string;
|
|
@@ -220,4 +222,5 @@ export default class Scheduler extends RestfulModel implements SchedulerProperti
|
|
|
220
222
|
save(params?: {} | SaveCallback, callback?: SaveCallback): Promise<this>;
|
|
221
223
|
getAvailableCalendars(): Promise<SchedulerAvailableCalendars[]>;
|
|
222
224
|
uploadImage(contentType: string, objectName: string): Promise<SchedulerUploadImageResponse>;
|
|
225
|
+
private validate;
|
|
223
226
|
}
|
package/lib/models/scheduler.js
CHANGED
|
@@ -178,7 +178,7 @@ var SchedulerBookingOpeningHours = /** @class */ (function (_super) {
|
|
|
178
178
|
return _this;
|
|
179
179
|
}
|
|
180
180
|
SchedulerBookingOpeningHours.attributes = {
|
|
181
|
-
|
|
181
|
+
accountId: attributes_1.default.String({
|
|
182
182
|
modelKey: 'accountId',
|
|
183
183
|
jsonKey: 'account_id',
|
|
184
184
|
}),
|
|
@@ -230,7 +230,7 @@ var SchedulerBooking = /** @class */ (function (_super) {
|
|
|
230
230
|
}),
|
|
231
231
|
confirmationEmailToHost: attributes_1.default.Boolean({
|
|
232
232
|
modelKey: 'confirmationEmailToHost',
|
|
233
|
-
jsonKey: '
|
|
233
|
+
jsonKey: 'confirmation_emails_to_host',
|
|
234
234
|
}),
|
|
235
235
|
confirmationMethod: attributes_1.default.String({
|
|
236
236
|
modelKey: 'confirmationMethod',
|
|
@@ -248,6 +248,10 @@ var SchedulerBooking = /** @class */ (function (_super) {
|
|
|
248
248
|
modelKey: 'minCancellationNotice',
|
|
249
249
|
jsonKey: 'min_cancellation_notice',
|
|
250
250
|
}),
|
|
251
|
+
intervalMinutes: attributes_1.default.Number({
|
|
252
|
+
modelKey: 'intervalMinutes',
|
|
253
|
+
jsonKey: 'interval_minutes',
|
|
254
|
+
}),
|
|
251
255
|
nameFieldHidden: attributes_1.default.Boolean({
|
|
252
256
|
modelKey: 'nameFieldHidden',
|
|
253
257
|
jsonKey: 'name_field_hidden',
|
|
@@ -356,6 +360,7 @@ var Scheduler = /** @class */ (function (_super) {
|
|
|
356
360
|
}
|
|
357
361
|
Scheduler.prototype.save = function (params, callback) {
|
|
358
362
|
if (params === void 0) { params = {}; }
|
|
363
|
+
this.validate();
|
|
359
364
|
return _super.prototype.save.call(this, params, callback);
|
|
360
365
|
};
|
|
361
366
|
Scheduler.prototype.getAvailableCalendars = function () {
|
|
@@ -396,6 +401,14 @@ var Scheduler = /** @class */ (function (_super) {
|
|
|
396
401
|
baseUrl: this.baseUrl,
|
|
397
402
|
});
|
|
398
403
|
};
|
|
404
|
+
Scheduler.prototype.validate = function () {
|
|
405
|
+
var _a, _b;
|
|
406
|
+
var bookingIntervalMinutes = (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.booking) === null || _b === void 0 ? void 0 : _b.intervalMinutes;
|
|
407
|
+
if (bookingIntervalMinutes !== undefined &&
|
|
408
|
+
(bookingIntervalMinutes <= 0 || bookingIntervalMinutes % 5 != 0)) {
|
|
409
|
+
throw new Error('SchedulerBooking.intervalMinutes must be a non-zero positive integer, divisible by 5.');
|
|
410
|
+
}
|
|
411
|
+
};
|
|
399
412
|
Scheduler.collectionName = 'manage/pages';
|
|
400
413
|
Scheduler.attributes = __assign(__assign({}, restful_model_1.default.attributes), { accessTokens: attributes_1.default.StringList({
|
|
401
414
|
modelKey: 'accessTokens',
|
package/lib/nylas-connection.js
CHANGED
|
@@ -193,30 +193,22 @@ var NylasConnection = /** @class */ (function () {
|
|
|
193
193
|
console.warn(warning);
|
|
194
194
|
}
|
|
195
195
|
if (response.status > 299) {
|
|
196
|
-
return response
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
}
|
|
207
|
-
return reject(error);
|
|
208
|
-
})
|
|
209
|
-
.catch(function () {
|
|
210
|
-
return response
|
|
211
|
-
.text()
|
|
212
|
-
.then(function (text) {
|
|
213
|
-
var error = new nylas_api_error_1.default(response.status, response.statusText, text);
|
|
196
|
+
return response.text().then(function (body) {
|
|
197
|
+
try {
|
|
198
|
+
var parsedApiError = JSON.parse(body);
|
|
199
|
+
var error = new nylas_api_error_1.default(response.status, parsedApiError.type, parsedApiError.message);
|
|
200
|
+
if (parsedApiError.missing_fields) {
|
|
201
|
+
error.missingFields = parsedApiError.missing_fields;
|
|
202
|
+
}
|
|
203
|
+
if (parsedApiError.server_error) {
|
|
204
|
+
error.serverError = parsedApiError.server_error;
|
|
205
|
+
}
|
|
214
206
|
return reject(error);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
var error = new nylas_api_error_1.default(response.status, response.statusText,
|
|
207
|
+
}
|
|
208
|
+
catch (e) {
|
|
209
|
+
var error = new nylas_api_error_1.default(response.status, response.statusText, body);
|
|
218
210
|
return reject(error);
|
|
219
|
-
}
|
|
211
|
+
}
|
|
220
212
|
});
|
|
221
213
|
}
|
|
222
214
|
else {
|
|
@@ -244,12 +236,14 @@ var NylasConnection = /** @class */ (function () {
|
|
|
244
236
|
return resolve(response.text());
|
|
245
237
|
}
|
|
246
238
|
else {
|
|
247
|
-
return response
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
239
|
+
return response.text().then(function (text) {
|
|
240
|
+
try {
|
|
241
|
+
return resolve(JSON.parse(text));
|
|
242
|
+
}
|
|
243
|
+
catch (e) {
|
|
244
|
+
return resolve(text);
|
|
245
|
+
}
|
|
246
|
+
});
|
|
253
247
|
}
|
|
254
248
|
}
|
|
255
249
|
})
|